4 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/6ee0412ee742/ changeset: 6ee0412ee742 user: jgoecks date: 2012-10-20 22:12:00 summary: Circster: transition paths when loading more detailed data. affected #: 1 file diff -r afc8e93452687063301398854dbcf0d450c8558c -r 6ee0412ee7424227548e5568765e4f99ad4a2a29 static/scripts/viz/circster.js --- a/static/scripts/viz/circster.js +++ b/static/scripts/viz/circster.js @@ -286,32 +286,7 @@ this.options.parent_elt.selectAll('g>path.chrom-background').transition().duration(1000).attr('d', new_d); - // -- Update chrom data. -- - var track = this.options.track, - chrom_arcs = this.options.chroms_layout, - chrom_data_paths = this.options.parent_elt.selectAll('g>path.chrom-data'), - num_paths = chrom_data_paths[0].length; - - if (num_paths > 0) { - var self = this; - $.when(track.get('data_manager').get_genome_wide_data(this.options.genome)).then(function(genome_wide_data) { - // Map chrom data to path data, filtering out null values. - var path_data = _.reject( _.map(genome_wide_data, function(chrom_data, i) { - var rval = null, - path_fn = self._compute_path_data(chrom_arcs[i], chrom_data); - if (path_fn) { - rval = path_fn(chrom_data.data); - } - return rval; - }), function(p_data) { return p_data === null; } ); - - // Transition each path. - chrom_data_paths.each(function(path, index) { - d3.select(this).transition().duration(1000).attr('d', path_data[index]); - }); - - }); - } + this._transition_chrom_data(); }, /** @@ -370,12 +345,47 @@ /* ----------------------- Internal Methods ------------------------- */ /** + * Transitions chrom data to new values (e.g new radius or data bounds). + */ + _transition_chrom_data: function() { + var track = this.options.track, + chrom_arcs = this.options.chroms_layout, + chrom_data_paths = this.options.parent_elt.selectAll('g>path.chrom-data'), + num_paths = chrom_data_paths[0].length; + + if (num_paths > 0) { + var self = this; + $.when(track.get('data_manager').get_genome_wide_data(this.options.genome)).then(function(genome_wide_data) { + // Map chrom data to path data, filtering out null values. + var path_data = _.reject( _.map(genome_wide_data, function(chrom_data, i) { + var rval = null, + path_fn = self._get_path_function(chrom_arcs[i], chrom_data); + if (path_fn) { + rval = path_fn(chrom_data.data); + } + return rval; + }), function(p_data) { return p_data === null; } ); + + // Transition each path. + chrom_data_paths.each(function(path, index) { + d3.select(this).transition().duration(1000).attr('d', path_data[index]); + }); + + }); + } + }, + + /** * Update data bounds. */ _update_data_bounds: function() { - //this.options.data_bounds = this.get_data_bounds(this.options.track.get_genome_wide_data(this.options.genome)); + var old_bounds = this.options.data_bounds; + this.options.data_bounds = this.get_data_bounds(this.options.track.get('data_manager').get_genome_wide_data(this.options.genome)); - // TODO: transition all paths to use the new data bounds. + // If bounds have changed, transition all paths to use the new data bounds. + if (this.options.data_bounds[0] < old_bounds[0] || this.options.data_bounds[1] > old_bounds[1]) { + this._transition_chrom_data(); + } }, /** @@ -422,7 +432,7 @@ /** * Returns data for creating a path for the given data using chrom_arc and data bounds. */ - _compute_path_data: function(chrom_arc, chrom_data) {}, + _get_path_function: function(chrom_arc, chrom_data) {}, /** * Returns arc layouts for genome's chromosomes/contigs. Arcs are arranged in a circle @@ -490,7 +500,7 @@ * chromosome. Attachs a dict with track and chrom name information to DOM element. */ _render_chrom_data: function(svg, chrom_arc, chrom_data) { - var path_data = this._compute_path_data(chrom_arc, chrom_data); + var path_data = this._get_path_function(chrom_arc, chrom_data); if (!path_data) { return null; } @@ -505,9 +515,9 @@ }, /** - * Returns data for creating a path for the given data using chrom_arc, radius bounds, and data bounds. + * Returns function for creating a path across the chrom arc. */ - _compute_path_data: function(chrom_arc, chrom_data) { + _get_path_function: function(chrom_arc, chrom_data) { // If no chrom data, return null. if (typeof chrom_data === "string" || !chrom_data.data || chrom_data.data.length === 0) { return null; https://bitbucket.org/galaxy/galaxy-central/changeset/96e230aed769/ changeset: 96e230aed769 user: jgoecks date: 2012-10-20 22:25:28 summary: Circster: code cleanup to remove use of options dictionary. affected #: 1 file diff -r 6ee0412ee7424227548e5568765e4f99ad4a2a29 -r 96e230aed76971953f62728c28b28730608ee2c9 static/scripts/viz/circster.js --- a/static/scripts/viz/circster.js +++ b/static/scripts/viz/circster.js @@ -214,16 +214,19 @@ /* ----------------------- Public Methods ------------------------- */ initialize: function(options) { - this.options = options; - this.options.bg_stroke = 'ccc'; + this.bg_stroke = 'ccc'; // Fill color when loading data. - this.options.loading_bg_fill = '000'; + this.loading_bg_fill = '000'; // Fill color when data has been loaded. - this.options.bg_fill = 'ccc'; - this.options.chroms_layout = this._chroms_layout(); - this.options.data_bounds = []; - this.options.scale = 1; - this.options.parent_elt = d3.select(this.$el[0]); + this.bg_fill = 'ccc'; + this.total_gap = options.total_gap; + this.track = options.track; + this.radius_bounds = options.radius_bounds; + this.genome = options.genome; + this.chroms_layout = this._chroms_layout(); + this.data_bounds = []; + this.scale = 1; + this.parent_elt = d3.select(this.$el[0]); }, /** @@ -231,17 +234,17 @@ */ render: function() { // -- Create track group element. -- - var track_parent_elt = this.options.parent_elt; + var track_parent_elt = this.parent_elt; if (!track_parent_elt) { console.log('no parent elt'); } // -- Render background arcs. -- - var genome_arcs = this.options.chroms_layout, + var genome_arcs = this.chroms_layout, arc_gen = d3.svg.arc() - .innerRadius(this.options.radius_bounds[0]) - .outerRadius(this.options.radius_bounds[1]), + .innerRadius(this.radius_bounds[0]) + .outerRadius(this.radius_bounds[1]), // Attach data to group element. chroms_elts = track_parent_elt.selectAll('g') @@ -251,8 +254,8 @@ chroms_paths = chroms_elts.append('path') .attr("d", arc_gen) .attr('class', 'chrom-background') - .style("stroke", this.options.bg_stroke) - .style("fill", this.options.loading_bg_fill); + .style("stroke", this.bg_stroke) + .style("fill", this.loading_bg_fill); // Append titles to paths. chroms_paths.append("title").text(function(d) { return d.data.chrom; }); @@ -260,14 +263,14 @@ // -- Render track data and, when track data is rendered, apply preferences and update chrom_elts fill. -- var self = this, - data_manager = self.options.track.get('data_manager'), + data_manager = self.track.get('data_manager'), // If track has a data manager, get deferred that resolves when data is ready. data_ready_deferred = (data_manager ? data_manager.data_is_ready() : true ); // When data is ready, render track. $.when(data_ready_deferred).then(function() { $.when(self._render_data(track_parent_elt)).then(function() { - chroms_paths.style("fill", self.options.bg_fill); + chroms_paths.style("fill", self.bg_fill); }); }); }, @@ -277,14 +280,14 @@ */ update_radius_bounds: function(radius_bounds) { // Update bounds. - this.options.radius_bounds = radius_bounds; + this.radius_bounds = radius_bounds; // -- Update background arcs. -- var new_d = d3.svg.arc() - .innerRadius(this.options.radius_bounds[0]) - .outerRadius(this.options.radius_bounds[1]); + .innerRadius(this.radius_bounds[0]) + .outerRadius(this.radius_bounds[1]); - this.options.parent_elt.selectAll('g>path.chrom-background').transition().duration(1000).attr('d', new_d); + this.parent_elt.selectAll('g>path.chrom-background').transition().duration(1000).attr('d', new_d); this._transition_chrom_data(); }, @@ -295,8 +298,8 @@ update_scale: function(new_scale) { // -- Update scale and return if new scale is less than old scale. -- - var old_scale = this.options.scale; - this.options.scale = new_scale; + var old_scale = this.scale; + this.scale = new_scale; if (new_scale <= old_scale) { return; } @@ -307,16 +310,16 @@ utils = new SVGUtils(); // Select all chrom data and filter to operate on those that are visible. - this.options.parent_elt.selectAll('path.chrom-data').filter(function(d, i) { + this.parent_elt.selectAll('path.chrom-data').filter(function(d, i) { return utils.is_visible(this); }).each(function(d, i) { // Now operating on a single path element representing chromosome data. var path_elt = d3.select(this), chrom = path_elt.attr('chrom'), - chrom_region = self.options.genome.get_chrom_region(chrom), + chrom_region = self.genome.get_chrom_region(chrom), // Get more detailde data for chrom. - data_deferred = self.options.track.get('data_manager').get_more_detailed_data(chrom_region, 'Coverage', 0, new_scale); + data_deferred = self.track.get('data_manager').get_more_detailed_data(chrom_region, 'Coverage', 0, new_scale); // When more data is available, use new data to redraw path. $.when(data_deferred).then(function(data) { @@ -327,15 +330,15 @@ self._update_data_bounds(); // Find chromosome arc to draw data on. - var chrom_arc = _.find(self.options.chroms_layout, function(layout) { + var chrom_arc = _.find(self.chroms_layout, function(layout) { return layout.data.chrom === chrom; }); // Add new data path and apply preferences. - var prefs = self.options.track.get('prefs'), + var prefs = self.track.get('prefs'), block_color = prefs.block_color; if (!block_color) { block_color = prefs.color; } - self._render_chrom_data(self.options.parent_elt, chrom_arc, data).style('stroke', block_color).style('fill', block_color); + self._render_chrom_data(self.parent_elt, chrom_arc, data).style('stroke', block_color).style('fill', block_color); }); }); @@ -348,14 +351,14 @@ * Transitions chrom data to new values (e.g new radius or data bounds). */ _transition_chrom_data: function() { - var track = this.options.track, - chrom_arcs = this.options.chroms_layout, - chrom_data_paths = this.options.parent_elt.selectAll('g>path.chrom-data'), + var track = this.track, + chrom_arcs = this.chroms_layout, + chrom_data_paths = this.parent_elt.selectAll('g>path.chrom-data'), num_paths = chrom_data_paths[0].length; if (num_paths > 0) { var self = this; - $.when(track.get('data_manager').get_genome_wide_data(this.options.genome)).then(function(genome_wide_data) { + $.when(track.get('data_manager').get_genome_wide_data(this.genome)).then(function(genome_wide_data) { // Map chrom data to path data, filtering out null values. var path_data = _.reject( _.map(genome_wide_data, function(chrom_data, i) { var rval = null, @@ -379,11 +382,11 @@ * Update data bounds. */ _update_data_bounds: function() { - var old_bounds = this.options.data_bounds; - this.options.data_bounds = this.get_data_bounds(this.options.track.get('data_manager').get_genome_wide_data(this.options.genome)); + var old_bounds = this.data_bounds; + this.data_bounds = this.get_data_bounds(this.track.get('data_manager').get_genome_wide_data(this.genome)); // If bounds have changed, transition all paths to use the new data bounds. - if (this.options.data_bounds[0] < old_bounds[0] || this.options.data_bounds[1] > old_bounds[1]) { + if (this.data_bounds[0] < old_bounds[0] || this.data_bounds[1] > old_bounds[1]) { this._transition_chrom_data(); } }, @@ -393,14 +396,14 @@ */ _render_data: function(svg) { var self = this, - chrom_arcs = this.options.chroms_layout, - track = this.options.track, + chrom_arcs = this.chroms_layout, + track = this.track, rendered_deferred = $.Deferred(); // When genome-wide data is available, render data. - $.when(track.get('data_manager').get_genome_wide_data(this.options.genome)).then(function(genome_wide_data) { + $.when(track.get('data_manager').get_genome_wide_data(this.genome)).then(function(genome_wide_data) { // Set bounds. - self.options.data_bounds = self.get_data_bounds(genome_wide_data); + self.data_bounds = self.get_data_bounds(genome_wide_data); // Merge chroms layout with data. layout_and_data = _.zip(chrom_arcs, genome_wide_data), @@ -416,7 +419,7 @@ var config = track.get('config'), block_color = config.get_value('block_color');; if (!block_color) { block_color = config.get_value('color'); } - self.options.parent_elt.selectAll('path.chrom-data').style('stroke', block_color).style('fill', block_color); + self.parent_elt.selectAll('path.chrom-data').style('stroke', block_color).style('fill', block_color); rendered_deferred.resolve(svg); }); @@ -440,10 +443,10 @@ */ _chroms_layout: function() { // Setup chroms layout using pie. - var chroms_info = this.options.genome.get_chroms_info(), + var chroms_info = this.genome.get_chroms_info(), pie_layout = d3.layout.pie().value(function(d) { return d.len; }).sort(null), init_arcs = pie_layout(chroms_info), - gap_per_chrom = this.options.total_gap / chroms_info.length, + gap_per_chrom = this.total_gap / chroms_info.length, chrom_arcs = _.map(init_arcs, function(arc, index) { // For short chroms, endAngle === startAngle. var new_endAngle = arc.endAngle - gap_per_chrom; @@ -461,8 +464,8 @@ initialize: function(options) { CircsterTrackView.prototype.initialize.call(this, options); - this.options.bg_stroke = 'fff'; - this.options.bg_fill = 'fff'; + this.bg_stroke = 'fff'; + this.bg_fill = 'fff'; }, /** @@ -525,8 +528,8 @@ // Radius scaler. var radius = d3.scale.linear() - .domain(this.options.data_bounds) - .range(this.options.radius_bounds); + .domain(this.data_bounds) + .range(this.radius_bounds); // Scaler for placing data points across arc. var angle = d3.scale.linear() https://bitbucket.org/galaxy/galaxy-central/changeset/043012c62cfc/ changeset: 043012c62cfc user: jgoecks date: 2012-10-20 22:39:39 summary: Circster, cleanup for fetching more data: do not fetch more data for summary tree and use linear function for fetching more bigwig data. affected #: 2 files diff -r 96e230aed76971953f62728c28b28730608ee2c9 -r 043012c62cfca6a30694445d47790726736c7032 static/scripts/viz/circster.js --- a/static/scripts/viz/circster.js +++ b/static/scripts/viz/circster.js @@ -167,7 +167,7 @@ }); // Render new track. - var track_index = this.track_views.length + var track_index = this.track_views.length, track_view_class = (new_track.get('track_type') === 'LineTrack' ? CircsterBigWigTrackView : CircsterSummaryTreeTrackView ), @@ -313,13 +313,21 @@ this.parent_elt.selectAll('path.chrom-data').filter(function(d, i) { return utils.is_visible(this); }).each(function(d, i) { - // Now operating on a single path element representing chromosome data. + // -- Now operating on a single path element representing chromosome data. -- + var path_elt = d3.select(this), chrom = path_elt.attr('chrom'), chrom_region = self.genome.get_chrom_region(chrom), + data_manager = self.track.get('data_manager'), + data_deferred; - // Get more detailde data for chrom. - data_deferred = self.track.get('data_manager').get_more_detailed_data(chrom_region, 'Coverage', 0, new_scale); + // If can't get more detailed data, return. + if (!data_manager.can_get_more_detailed_data(chrom_region)) { + return; + } + + // -- Get more detailed data. -- + data_deferred = self.track.get('data_manager').get_more_detailed_data(chrom_region, 'Coverage', 0, new_scale); // When more data is available, use new data to redraw path. $.when(data_deferred).then(function(data) { @@ -417,7 +425,7 @@ // Apply prefs to all track data. var config = track.get('config'), - block_color = config.get_value('block_color');; + block_color = config.get_value('block_color'); if (!block_color) { block_color = config.get_value('color'); } self.parent_elt.selectAll('path.chrom-data').style('stroke', block_color).style('fill', block_color); diff -r 96e230aed76971953f62728c28b28730608ee2c9 -r 043012c62cfca6a30694445d47790726736c7032 static/scripts/viz/visualization.js --- a/static/scripts/viz/visualization.js +++ b/static/scripts/viz/visualization.js @@ -429,6 +429,17 @@ }, /** + * Returns true if more detailed data can be obtained for entry. + */ + can_get_more_detailed_data: function(region) { + var cur_data = this.get_elt(region); + + // Can only get more detailed data for bigwig data that has less than 8000 data points. + // Summary tree returns *way* too much data, and 8000 data points ~ 500KB. + return (cur_data.dataset_type === 'bigwig' && cur_data.data.length < 8000); + }, + + /** * Returns more detailed data for an entry. */ get_more_detailed_data: function(region, mode, resolution, detail_multiplier, extra_params) { @@ -443,7 +454,8 @@ // Use additional parameters to get more detailed data. if (cur_data.dataset_type === 'bigwig') { - extra_params.num_samples = cur_data.data.length * detail_multiplier; + // FIXME: constant should go somewhere. + extra_params.num_samples = 1000 * detail_multiplier; } else if (cur_data.dataset_type === 'summary_tree') { extra_params.level = Math.min(cur_data.level - 1, 2); https://bitbucket.org/galaxy/galaxy-central/changeset/d2c998e06f0e/ changeset: d2c998e06f0e user: jgoecks date: 2012-10-20 22:40:38 summary: Pack scripts. affected #: 4 files diff -r 043012c62cfca6a30694445d47790726736c7032 -r d2c998e06f0ef7b117bf2e05150bbed877d5dcb3 static/scripts/packed/utils/config.js --- a/static/scripts/packed/utils/config.js +++ b/static/scripts/packed/utils/config.js @@ -1,1 +1,1 @@ -define(["libs/underscore","viz/trackster/util"],function(b,e){var c=Backbone.Model.extend({defaults:{key:null,value:null,type:"text",label:null,options:null,hidden:false},initialize:function(f){var g=this.get("key");this.set("id",g);var h=b.find(c.known_settings,function(i){return i.key===g});if(h){this.set(b.extend({},h,f))}if(this.get("type")==="color"){this.set("value",e.get_random_color())}this.on("change:value",this.cast_value,this)},cast_value:function(){var f=this.get("type"),g=this.get("value");if(f==="float"){g=parseFloat(g)}else{if(f==="int"){g=parseInt(g,10)}}this.set("value")}},{known_settings:[{key:"name",label:"Name",type:"text",default_value:""},{key:"color",label:"Color",type:"color",default_value:undefined},{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:32,hidden:true},{key:"pos_color",label:"Positive Color",type:"color",default_value:"4169E1"},{key:"negative_color",label:"Negative Color",type:"color",default_value:"FF8C00"},{key:"block_color",label:"Block color",type:"color",default_value:undefined},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_insertions",label:"Show insertions",type:"bool",default_value:false},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"reverse_strand_color",label:"Antisense strand color",type:"color",default_value:undefined},{key:"show_differences",label:"Show differences only",type:"bool",default_value:true},{key:"histogram_max",label:"Histogram maximum",type:"float",default_value:null,help:"Clear value to set automatically"},{key:"mode",type:"string",default_value:this.mode,hidden:true}]});var d=Backbone.Collection.extend({model:c,to_key_value_dict:function(){var f={};this.each(function(g){f[g.get("key")]=g.get("value")});return f},restore_values:function(g){var f=this;b.keys(g,function(h){var i=f.find(function(j){return j.get("key")===h});if(i){i.set("value",g.key)}})},get_value:function(f){return this.get(f).get("value")}},{from_config_dict:function(g){var f=b.map(b.keys(g),function(h){return{key:h,value:g[h]}});return new d(f)}});var a=Backbone.View.extend({className:"config-settings-view",render:function(){var i=this.model;var f=this.$el;var h;function g(n,j){for(var r=0;r<n.length;r++){h=n[r];if(h.hidden){continue}var l="param_"+r;var v=i.values[h.key];var x=$("<div class='form-row' />").appendTo(j);x.append($("<label />").attr("for",l).text(h.label+":"));if(type==="bool"){x.append($('<input type="checkbox" />').attr("id",l).attr("name",l).attr("checked",v))}else{if(type==="text"){x.append($('<input type="text"/>').attr("id",l).val(v).click(function(){$(this).select()}))}else{if(type==="select"){var t=$("<select />").attr("id",l);for(var p=0;p<h.options.length;p++){$("<option/>").text(h.options[p].label).attr("value",h.options[p].value).appendTo(t)}t.val(v);x.append(t)}else{if(type==="color"){var w=$("<div/>").appendTo(x),s=$("<input />").attr("id",l).attr("name",l).val(v).css("float","left").appendTo(w).click(function(z){$(".bs-tooltip").removeClass("in");var y=$(this).siblings(".bs-tooltip").addClass("in");y.css({left:$(this).position().left+$(this).width()+5,top:$(this).position().top-($(y).height()/2)+($(this).height()/2)}).show();y.click(function(A){A.stopPropagation()});$(document).bind("click.color-picker",function(){y.hide();$(document).unbind("click.color-picker")});z.stopPropagation()}),q=$("<a href='javascript:void(0)'/>").addClass("icon-button arrow-circle").appendTo(w).attr("title","Set new random color").tooltip(),u=$("<div class='bs-tooltip right' style='position: absolute;' />").appendTo(w).hide(),m=$("<div class='tooltip-inner' style='text-align: inherit'></div>").appendTo(u),k=$("<div class='tooltip-arrow'></div>").appendTo(u),o=$.farbtastic(m,{width:100,height:100,callback:s,color:v});w.append($("<div/>").css("clear","both"));(function(y){q.click(function(){y.setColor(e.get_random_color())})})(o)}else{x.append($("<input />").attr("id",l).attr("name",l).val(v))}}}}if(h.help){x.append($("<div class='help'/>").text(h.help))}}}g(this.params,f);return this},render_in_modal:function(){var h=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},f=function(){this.update_from_form();hide_modal();$(window).unbind("keypress.check_enter_esc")},g=function(i){if((i.keyCode||i.which)===27){h()}else{if((i.keyCode||i.which)===13){f()}}};$(window).bind("keypress.check_enter_esc",g);if(this.$el.children().length===0){this.render()}show_modal("Configure",drawable.config.build_form(),{Cancel:h,OK:f})},update_from_form:function(){var f=this;this.collection.each(function(h,g){if(!h.get("hidden")){var j="param_"+g;var i=f.$el.find("#"+j).val();if(type==="bool"){i=container.find("#"+j).is(":checked")}h.set("value",i)}})}});return{ConfigSettingCollection:d,ConfigSettingCollectionView:a}}); \ No newline at end of file +define(["libs/underscore","viz/trackster/util"],function(b,e){var c=Backbone.Model.extend({initialize:function(f){var g=this.get("key");this.set("id",g);var h=b.find(c.known_settings_defaults,function(i){return i.key===g});if(h){this.set(b.extend({},h,f))}if(this.get("type")==="color"&&!this.get("value")){this.set("value",e.get_random_color())}this.on("change:value",this.cast_value,this)},cast_value:function(){var f=this.get("type"),g=this.get("value");if(f==="float"){g=parseFloat(g)}else{if(f==="int"){g=parseInt(g,10)}}this.set("value")}},{known_settings_defaults:[{key:"name",label:"Name",type:"text",default_value:""},{key:"color",label:"Color",type:"color",default_value:null},{key:"min_value",label:"Min Value",type:"float",default_value:null},{key:"max_value",label:"Max Value",type:"float",default_value:null},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"height",type:"int",default_value:32,hidden:true},{key:"pos_color",label:"Positive Color",type:"color",default_value:"4169E1"},{key:"negative_color",label:"Negative Color",type:"color",default_value:"FF8C00"},{key:"block_color",label:"Block color",type:"color",default_value:null},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_insertions",label:"Show insertions",type:"bool",default_value:false},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"reverse_strand_color",label:"Antisense strand color",type:"color",default_value:null},{key:"show_differences",label:"Show differences only",type:"bool",default_value:true},{key:"histogram_max",label:"Histogram maximum",type:"float",default_value:null,help:"Clear value to set automatically"},{key:"mode",type:"string",default_value:this.mode,hidden:true}]});var d=Backbone.Collection.extend({model:c,to_key_value_dict:function(){var f={};this.each(function(g){f[g.get("key")]=g.get("value")});return f},get_value:function(f){var g=this.get(f);if(g){return g.get("value")}return undefined}},{from_config_dict:function(g){var f=b.map(b.keys(g),function(h){return{key:h,value:g[h]}});return new d(f)}});var a=Backbone.View.extend({className:"config-settings-view",render:function(){var i=this.model;var f=this.$el;var h;function g(n,j){for(var r=0;r<n.length;r++){h=n[r];if(h.hidden){continue}var l="param_"+r;var v=i.values[h.key];var x=$("<div class='form-row' />").appendTo(j);x.append($("<label />").attr("for",l).text(h.label+":"));if(type==="bool"){x.append($('<input type="checkbox" />').attr("id",l).attr("name",l).attr("checked",v))}else{if(type==="text"){x.append($('<input type="text"/>').attr("id",l).val(v).click(function(){$(this).select()}))}else{if(type==="select"){var t=$("<select />").attr("id",l);for(var p=0;p<h.options.length;p++){$("<option/>").text(h.options[p].label).attr("value",h.options[p].value).appendTo(t)}t.val(v);x.append(t)}else{if(type==="color"){var w=$("<div/>").appendTo(x),s=$("<input />").attr("id",l).attr("name",l).val(v).css("float","left").appendTo(w).click(function(z){$(".bs-tooltip").removeClass("in");var y=$(this).siblings(".bs-tooltip").addClass("in");y.css({left:$(this).position().left+$(this).width()+5,top:$(this).position().top-($(y).height()/2)+($(this).height()/2)}).show();y.click(function(A){A.stopPropagation()});$(document).bind("click.color-picker",function(){y.hide();$(document).unbind("click.color-picker")});z.stopPropagation()}),q=$("<a href='javascript:void(0)'/>").addClass("icon-button arrow-circle").appendTo(w).attr("title","Set new random color").tooltip(),u=$("<div class='bs-tooltip right' style='position: absolute;' />").appendTo(w).hide(),m=$("<div class='tooltip-inner' style='text-align: inherit'></div>").appendTo(u),k=$("<div class='tooltip-arrow'></div>").appendTo(u),o=$.farbtastic(m,{width:100,height:100,callback:s,color:v});w.append($("<div/>").css("clear","both"));(function(y){q.click(function(){y.setColor(e.get_random_color())})})(o)}else{x.append($("<input />").attr("id",l).attr("name",l).val(v))}}}}if(h.help){x.append($("<div class='help'/>").text(h.help))}}}g(this.params,f);return this},render_in_modal:function(){var h=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},f=function(){this.update_from_form();hide_modal();$(window).unbind("keypress.check_enter_esc")},g=function(i){if((i.keyCode||i.which)===27){h()}else{if((i.keyCode||i.which)===13){f()}}};$(window).bind("keypress.check_enter_esc",g);if(this.$el.children().length===0){this.render()}show_modal("Configure",drawable.config.build_form(),{Cancel:h,OK:f})},update_from_form:function(){var f=this;this.collection.each(function(h,g){if(!h.get("hidden")){var j="param_"+g;var i=f.$el.find("#"+j).val();if(type==="bool"){i=container.find("#"+j).is(":checked")}h.set("value",i)}})}});return{ConfigSettingCollection:d,ConfigSettingCollectionView:a}}); \ No newline at end of file diff -r 043012c62cfca6a30694445d47790726736c7032 -r d2c998e06f0ef7b117bf2e05150bbed877d5dcb3 static/scripts/packed/viz/circster.js --- a/static/scripts/packed/viz/circster.js +++ b/static/scripts/packed/viz/circster.js @@ -1,1 +1,1 @@ -define(["libs/underscore","libs/d3","viz/visualization"],function(g,j,h){var k=Backbone.Model.extend({is_visible:function(o,l){var m=o.getBoundingClientRect(),n=$("svg")[0].getBoundingClientRect();if(m.right<0||m.left>n.right||m.bottom<0||m.top>n.bottom){return false}return true}});var c=Backbone.Model.extend({defaults:{prefs:{color:"#ccc"}}});var a=Backbone.View.extend({className:"circster",initialize:function(l){this.total_gap=l.total_gap;this.genome=l.genome;this.dataset_arc_height=l.dataset_arc_height;this.track_gap=5;this.label_arc_height=20;this.scale=1;this.track_views=null;this.model.get("tracks").on("add",this.add_track,this)},get_tracks_bounds:function(){var n=this.dataset_arc_height,l=Math.min(this.$el.width(),this.$el.height()),p=l/2-this.model.get("tracks").length*(this.dataset_arc_height+this.track_gap)-(this.label_arc_height+this.track_gap),o=j.range(p,l/2,this.dataset_arc_height+this.track_gap);var m=this;return g.map(o,function(q){return[q,q+m.dataset_arc_height]})},render:function(){var o=this,q=this.dataset_arc_height,r=o.$el.width(),l=o.$el.height(),p=this.model.get("tracks"),s=this.get_tracks_bounds(),n=j.select(o.$el[0]).append("svg").attr("width",r).attr("height",l).attr("pointer-events","all").append("svg:g").call(j.behavior.zoom().on("zoom",function(){var t=j.event.scale;n.attr("transform","translate("+j.event.translate+") scale("+t+")");if(o.scale!==t){if(o.zoom_drag_timeout){clearTimeout(o.zoom_drag_timeout)}o.zoom_drag_timeout=setTimeout(function(){g.each(o.track_views,function(u){u.update_scale(t)})},400)}})).attr("transform","translate("+r/2+","+l/2+")").append("svg:g").attr("class","tracks");this.track_views=p.map(function(t,u){track_view_class=(t.get("track_type")==="LineTrack"?d:e);return new track_view_class({el:n.append("g")[0],track:t,radius_bounds:s[u],genome:o.genome,total_gap:o.total_gap})});g.each(this.track_views,function(t){t.render()});var m=s[p.length];m[1]=m[0];this.label_track_view=new b({el:n.append("g")[0],track:new c(),radius_bounds:m,genome:o.genome,total_gap:o.total_gap});this.label_track_view.render()},add_track:function(o){var n=this.get_tracks_bounds();g.each(this.track_views,function(p,q){p.update_radius_bounds(n[q])});var m=this.track_views.length;track_view_class=(o.get("track_type")==="LineTrack"?d:e),track_view=new track_view_class({el:j.select("g.tracks").append("g")[0],track:o,radius_bounds:n[m],genome:this.genome,total_gap:this.total_gap});track_view.render();this.track_views.push(track_view);var l=n[n.length-1];l[1]=l[0];this.label_track_view.update_radius_bounds(l)}});var i=Backbone.View.extend({tagName:"g",initialize:function(l){this.options=l;this.options.bg_stroke="ccc";this.options.loading_bg_fill="000";this.options.bg_fill="ccc";this.options.chroms_layout=this._chroms_layout();this.options.data_bounds=[];this.options.scale=1;this.options.parent_elt=j.select(this.$el[0])},render:function(){var p=this.options.parent_elt;if(!p){console.log("no parent elt")}var o=this.options.chroms_layout,r=j.svg.arc().innerRadius(this.options.radius_bounds[0]).outerRadius(this.options.radius_bounds[1]),l=p.selectAll("g").data(o).enter().append("svg:g"),n=l.append("path").attr("d",r).attr("class","chrom-background").style("stroke",this.options.bg_stroke).style("fill",this.options.loading_bg_fill);n.append("title").text(function(t){return t.data.chrom});var m=this,q=m.options.track.get("data_manager"),s=(q?q.data_is_ready():true);$.when(s).then(function(){$.when(m._render_data(p)).then(function(){var t=m.options.track.get("prefs"),u=t.block_color;if(!u){u=t.color}p.selectAll("path.chrom-data").style("stroke",u).style("fill",u);n.style("fill",m.options.bg_fill)})})},update_radius_bounds:function(r){this.options.radius_bounds=r;var p=j.svg.arc().innerRadius(this.options.radius_bounds[0]).outerRadius(this.options.radius_bounds[1]);this.options.parent_elt.selectAll("g>path.chrom-background").transition().duration(1000).attr("d",p);var m=this.options.track,o=this.options.chroms_layout,l=this.options.parent_elt.selectAll("g>path.chrom-data"),q=l[0].length;if(q>0){var n=this;$.when(m.get("data_manager").get_genome_wide_data(this.options.genome)).then(function(t){var s=g.reject(g.map(t,function(u,v){var w=null,x=n._compute_path_data(o[v],u);if(x){w=x(u.data)}return w}),function(u){return u===null});l.each(function(v,u){j.select(this).transition().duration(1000).attr("d",s[u])})})}},update_scale:function(o){var n=this.options.scale;this.options.scale=o;if(o<=n){return}var m=this,l=new k();this.options.parent_elt.selectAll("path.chrom-data").filter(function(q,p){return l.is_visible(this)}).each(function(u,r){var t=j.select(this),q=t.attr("chrom"),s=m.options.genome.get_chrom_region(q),p=m.options.track.get("data_manager").get_more_detailed_data(s,"Coverage",0,o);$.when(p).then(function(y){t.remove();m._update_data_bounds();var x=g.find(m.options.chroms_layout,function(z){return z.data.chrom===q});var v=m.options.track.get("prefs"),w=v.block_color;if(!w){w=v.color}m._render_chrom_data(m.options.parent_elt,x,y).style("stroke",w).style("fill",w)})});return m},_update_data_bounds:function(){},_render_data:function(o){var n=this,m=this.options.chroms_layout,l=this.options.track,p=$.Deferred();$.when(l.get("data_manager").get_genome_wide_data(this.options.genome)).then(function(q){n.options.data_bounds=n.get_data_bounds(q);layout_and_data=g.zip(m,q),chroms_data_layout=g.map(layout_and_data,function(r){var s=r[0],t=r[1];return n._render_chrom_data(o,s,t)});p.resolve(o)});return p},_render_chrom_data:function(l,m,n){},_compute_path_data:function(m,l){},_chroms_layout:function(){var m=this.options.genome.get_chroms_info(),o=j.layout.pie().value(function(q){return q.len}).sort(null),p=o(m),l=this.options.total_gap/m.length,n=g.map(p,function(s,r){var q=s.endAngle-l;s.endAngle=(q>s.startAngle?q:s.startAngle);return s});return n}});var b=i.extend({initialize:function(l){i.prototype.initialize.call(this,l);this.options.bg_stroke="fff";this.options.bg_fill="fff"},_render_data:function(m){var l=m.selectAll("g");l.selectAll("path").attr("id",function(n){return"label-"+n.data.chrom});l.append("svg:text").filter(function(n){return n.endAngle-n.startAngle>0.08}).attr("text-anchor","middle").append("svg:textPath").attr("xlink:href",function(n){return"#label-"+n.data.chrom}).attr("startOffset","25%").text(function(n){return n.data.chrom})}});var f=i.extend({_render_chrom_data:function(l,o,m){var p=this._compute_path_data(o,m);if(!p){return null}var n=l.datum(m.data),q=n.append("path").attr("class","chrom-data").attr("chrom",o.data.chrom).attr("d",p);return q},_compute_path_data:function(o,n){if(typeof n==="string"||!n.data||n.data.length===0){return null}var l=j.scale.linear().domain(this.options.data_bounds).range(this.options.radius_bounds);var p=j.scale.linear().domain([0,n.data.length]).range([o.startAngle,o.endAngle]);var m=j.svg.line.radial().interpolate("linear").radius(function(q){return l(q[1])}).angle(function(r,q){return p(q)});return j.svg.area.radial().interpolate(m.interpolate()).innerRadius(l(0)).outerRadius(m.radius()).angle(m.angle())},get_data_bounds:function(l){}});var e=f.extend({get_data_bounds:function(m){var l=g.map(m,function(n){if(typeof n==="string"||!n.max){return 0}return n.max});return[0,(l&&typeof l!=="string"?g.max(l):0)]}});var d=f.extend({get_data_bounds:function(m){var l=g.flatten(g.map(m,function(n){if(n){return g.map(n.data,function(o){return o[1]})}else{return 0}}));return[g.min(l),g.max(l)]}});return{CircsterView:a}}); \ No newline at end of file +define(["libs/underscore","libs/d3","viz/visualization"],function(g,j,h){var k=Backbone.Model.extend({is_visible:function(o,l){var m=o.getBoundingClientRect(),n=$("svg")[0].getBoundingClientRect();if(m.right<0||m.left>n.right||m.bottom<0||m.top>n.bottom){return false}return true}});var c=Backbone.Model.extend({defaults:{prefs:{color:"#ccc"}}});var a=Backbone.View.extend({className:"circster",initialize:function(l){this.total_gap=l.total_gap;this.genome=l.genome;this.dataset_arc_height=l.dataset_arc_height;this.track_gap=5;this.label_arc_height=20;this.scale=1;this.track_views=null;this.model.get("tracks").on("add",this.add_track,this);this.model.get("tracks").on("remove",this.remove_track,this)},get_tracks_bounds:function(){var n=this.dataset_arc_height,l=Math.min(this.$el.width(),this.$el.height()),p=l/2-this.model.get("tracks").length*(this.dataset_arc_height+this.track_gap)-(this.label_arc_height+this.track_gap),o=j.range(p,l/2,this.dataset_arc_height+this.track_gap);var m=this;return g.map(o,function(q){return[q,q+m.dataset_arc_height]})},render:function(){var o=this,q=this.dataset_arc_height,r=o.$el.width(),l=o.$el.height(),p=this.model.get("tracks"),s=this.get_tracks_bounds(),n=j.select(o.$el[0]).append("svg").attr("width",r).attr("height",l).attr("pointer-events","all").append("svg:g").call(j.behavior.zoom().on("zoom",function(){var t=j.event.scale;n.attr("transform","translate("+j.event.translate+") scale("+t+")");if(o.scale!==t){if(o.zoom_drag_timeout){clearTimeout(o.zoom_drag_timeout)}o.zoom_drag_timeout=setTimeout(function(){g.each(o.track_views,function(u){u.update_scale(t)})},400)}})).attr("transform","translate("+r/2+","+l/2+")").append("svg:g").attr("class","tracks");this.track_views=p.map(function(t,u){track_view_class=(t.get("track_type")==="LineTrack"?d:e);return new track_view_class({el:n.append("g")[0],track:t,radius_bounds:s[u],genome:o.genome,total_gap:o.total_gap})});g.each(this.track_views,function(t){t.render()});var m=s[p.length];m[1]=m[0];this.label_track_view=new b({el:n.append("g")[0],track:new c(),radius_bounds:m,genome:o.genome,total_gap:o.total_gap});this.label_track_view.render()},add_track:function(p){var o=this.get_tracks_bounds();g.each(this.track_views,function(r,s){r.update_radius_bounds(o[s])});var n=this.track_views.length,q=(p.get("track_type")==="LineTrack"?d:e),l=new q({el:j.select("g.tracks").append("g")[0],track:p,radius_bounds:o[n],genome:this.genome,total_gap:this.total_gap});l.render();this.track_views.push(l);var m=o[o.length-1];m[1]=m[0];this.label_track_view.update_radius_bounds(m)},remove_track:function(m,o,n){var l=this.track_views[n.index];this.track_views.splice(n.index,1);l.$el.remove();var p=this.get_tracks_bounds();g.each(this.track_views,function(q,r){q.update_radius_bounds(p[r])})}});var i=Backbone.View.extend({tagName:"g",initialize:function(l){this.bg_stroke="ccc";this.loading_bg_fill="000";this.bg_fill="ccc";this.total_gap=l.total_gap;this.track=l.track;this.radius_bounds=l.radius_bounds;this.genome=l.genome;this.chroms_layout=this._chroms_layout();this.data_bounds=[];this.scale=1;this.parent_elt=j.select(this.$el[0])},render:function(){var p=this.parent_elt;if(!p){console.log("no parent elt")}var o=this.chroms_layout,r=j.svg.arc().innerRadius(this.radius_bounds[0]).outerRadius(this.radius_bounds[1]),l=p.selectAll("g").data(o).enter().append("svg:g"),n=l.append("path").attr("d",r).attr("class","chrom-background").style("stroke",this.bg_stroke).style("fill",this.loading_bg_fill);n.append("title").text(function(t){return t.data.chrom});var m=this,q=m.track.get("data_manager"),s=(q?q.data_is_ready():true);$.when(s).then(function(){$.when(m._render_data(p)).then(function(){n.style("fill",m.bg_fill)})})},update_radius_bounds:function(m){this.radius_bounds=m;var l=j.svg.arc().innerRadius(this.radius_bounds[0]).outerRadius(this.radius_bounds[1]);this.parent_elt.selectAll("g>path.chrom-background").transition().duration(1000).attr("d",l);this._transition_chrom_data()},update_scale:function(o){var n=this.scale;this.scale=o;if(o<=n){return}var m=this,l=new k();this.parent_elt.selectAll("path.chrom-data").filter(function(q,p){return l.is_visible(this)}).each(function(v,r){var u=j.select(this),q=u.attr("chrom"),t=m.genome.get_chrom_region(q),s=m.track.get("data_manager"),p;if(!s.can_get_more_detailed_data(t)){return}p=m.track.get("data_manager").get_more_detailed_data(t,"Coverage",0,o);$.when(p).then(function(z){u.remove();m._update_data_bounds();var y=g.find(m.chroms_layout,function(A){return A.data.chrom===q});var w=m.track.get("prefs"),x=w.block_color;if(!x){x=w.color}m._render_chrom_data(m.parent_elt,y,z).style("stroke",x).style("fill",x)})});return m},_transition_chrom_data:function(){var m=this.track,o=this.chroms_layout,l=this.parent_elt.selectAll("g>path.chrom-data"),p=l[0].length;if(p>0){var n=this;$.when(m.get("data_manager").get_genome_wide_data(this.genome)).then(function(r){var q=g.reject(g.map(r,function(s,t){var u=null,v=n._get_path_function(o[t],s);if(v){u=v(s.data)}return u}),function(s){return s===null});l.each(function(t,s){j.select(this).transition().duration(1000).attr("d",q[s])})})}},_update_data_bounds:function(){var l=this.data_bounds;this.data_bounds=this.get_data_bounds(this.track.get("data_manager").get_genome_wide_data(this.genome));if(this.data_bounds[0]<l[0]||this.data_bounds[1]>l[1]){this._transition_chrom_data()}},_render_data:function(o){var n=this,m=this.chroms_layout,l=this.track,p=$.Deferred();$.when(l.get("data_manager").get_genome_wide_data(this.genome)).then(function(s){n.data_bounds=n.get_data_bounds(s);layout_and_data=g.zip(m,s),chroms_data_layout=g.map(layout_and_data,function(t){var u=t[0],v=t[1];return n._render_chrom_data(o,u,v)});var q=l.get("config"),r=q.get_value("block_color");if(!r){r=q.get_value("color")}n.parent_elt.selectAll("path.chrom-data").style("stroke",r).style("fill",r);p.resolve(o)});return p},_render_chrom_data:function(l,m,n){},_get_path_function:function(m,l){},_chroms_layout:function(){var m=this.genome.get_chroms_info(),o=j.layout.pie().value(function(q){return q.len}).sort(null),p=o(m),l=this.total_gap/m.length,n=g.map(p,function(s,r){var q=s.endAngle-l;s.endAngle=(q>s.startAngle?q:s.startAngle);return s});return n}});var b=i.extend({initialize:function(l){i.prototype.initialize.call(this,l);this.bg_stroke="fff";this.bg_fill="fff"},_render_data:function(m){var l=m.selectAll("g");l.selectAll("path").attr("id",function(n){return"label-"+n.data.chrom});l.append("svg:text").filter(function(n){return n.endAngle-n.startAngle>0.08}).attr("text-anchor","middle").append("svg:textPath").attr("xlink:href",function(n){return"#label-"+n.data.chrom}).attr("startOffset","25%").text(function(n){return n.data.chrom})}});var f=i.extend({_render_chrom_data:function(l,o,m){var p=this._get_path_function(o,m);if(!p){return null}var n=l.datum(m.data),q=n.append("path").attr("class","chrom-data").attr("chrom",o.data.chrom).attr("d",p);return q},_get_path_function:function(o,n){if(typeof n==="string"||!n.data||n.data.length===0){return null}var l=j.scale.linear().domain(this.data_bounds).range(this.radius_bounds);var p=j.scale.linear().domain([0,n.data.length]).range([o.startAngle,o.endAngle]);var m=j.svg.line.radial().interpolate("linear").radius(function(q){return l(q[1])}).angle(function(r,q){return p(q)});return j.svg.area.radial().interpolate(m.interpolate()).innerRadius(l(0)).outerRadius(m.radius()).angle(m.angle())},get_data_bounds:function(l){}});var e=f.extend({get_data_bounds:function(m){var l=g.map(m,function(n){if(typeof n==="string"||!n.max){return 0}return n.max});return[0,(l&&typeof l!=="string"?g.max(l):0)]}});var d=f.extend({get_data_bounds:function(m){var l=g.flatten(g.map(m,function(n){if(n){return g.map(n.data,function(o){return o[1]})}else{return 0}}));return[g.min(l),g.max(l)]}});return{CircsterView:a}}); \ No newline at end of file diff -r 043012c62cfca6a30694445d47790726736c7032 -r d2c998e06f0ef7b117bf2e05150bbed877d5dcb3 static/scripts/packed/viz/trackster_ui.js --- a/static/scripts/packed/viz/trackster_ui.js +++ b/static/scripts/packed/viz/trackster_ui.js @@ -1,1 +1,1 @@ -define(["base","libs/underscore","viz/trackster/slotting","viz/trackster/painters","viz/trackster/tracks","viz/visualization"],function(g,c,h,e,b,d){var a=b.object_from_template;var f=g.Base.extend({initialize:function(j){this.baseURL=j},createButtonMenu:function(){var j=this,k=create_icon_buttons_menu([{icon_class:"plus-button",title:"Add tracks",on_click:function(){d.select_datasets(select_datasets_url,add_track_async_url,view.dbkey,function(l){c.each(l,function(m){view.add_drawable(a(m,view,view))})})}},{icon_class:"block--plus",title:"Add group",on_click:function(){view.add_drawable(new b.DrawableGroup(view,view,{name:"New Group"}))}},{icon_class:"bookmarks",title:"Bookmarks",on_click:function(){parent.force_right_panel(($("div#right").css("right")=="0px"?"hide":"show"))}},{icon_class:"globe",title:"Circster",on_click:function(){window.location=j.baseURL+"visualization/circster?id="+view.vis_id}},{icon_class:"disk--arrow",title:"Save",on_click:function(){show_modal("Saving...","progress");var l=[];$(".bookmark").each(function(){l.push({position:$(this).children(".position").text(),annotation:$(this).children(".annotation").text()})});var m=(view.overview_drawable?view.overview_drawable.name:null),n={id:view.vis_id,title:view.name,dbkey:view.dbkey,type:"trackster",datasets:view.to_dict(),viewport:{chrom:view.chrom,start:view.low,end:view.high,overview:m},bookmarks:l};$.ajax({url:galaxy_paths.get("visualization_url"),type:"POST",dataType:"json",data:{vis_json:JSON.stringify(n)}}).success(function(o){hide_modal();view.vis_id=o.vis_id;view.has_changes=false;window.history.pushState({},"",o.url+window.location.hash)}).error(function(){show_modal("Could Not Save","Could not save visualization. Please try again later.",{Close:hide_modal})})}},{icon_class:"cross-circle",title:"Close",on_click:function(){window.location=j.baseURL+"visualization/list"}}],{tooltip_config:{placement:"bottom"}});this.buttonMenu=k;return k},add_bookmarks:function(){var j=this,k=this.baseURL;show_modal("Select dataset for new bookmarks","progress");$.ajax({url:this.baseURL+"/visualization/list_histories",data:{"f-dbkey":view.dbkey},error:function(){alert("Grid failed")},success:function(l){show_modal("Select dataset for new bookmarks",l,{Cancel:function(){hide_modal()},Insert:function(){$("input[name=id]:checked,input[name=ldda_ids]:checked").first().each(function(){var m,n=$(this).val();if($(this).attr("name")==="id"){m={hda_id:n}}else{m={ldda_id:n}}$.ajax({url:this.baseURL+"/visualization/bookmarks_from_dataset",data:m,dataType:"json"}).then(function(o){for(i=0;i<o.data.length;i++){var p=o.data[i];j.add_bookmark(p[0],p[1])}})});hide_modal()}})}})},add_bookmark:function(n,l,j){var p=$("#bookmarks-container"),r=$("<div/>").addClass("bookmark").appendTo(p);var s=$("<div/>").addClass("position").appendTo(r),o=$("<a href=''/>").text(n).appendTo(s).click(function(){view.go_to(n);return false}),m=$("<div/>").text(l).appendTo(r);if(j){var q=$("<div/>").addClass("delete-icon-container").prependTo(r).click(function(){r.slideUp("fast");r.remove();view.has_changes=true;return false}),k=$("<a href=''/>").addClass("icon-button delete").appendTo(q);m.make_text_editable({num_rows:3,use_textarea:true,help_text:"Edit bookmark note"}).addClass("annotation")}view.has_changes=true;return r},create_visualization:function(o,j,n,p,m){var l=this,k=new b.View(o);k.editor=true;$.when(k.load_chroms_deferred).then(function(){if(j){var y=j.chrom,q=j.start,v=j.end,s=j.overview;if(y&&(q!==undefined)&&v){k.change_chrom(y,q,v)}}if(n){var t,r,u;for(var w=0;w<n.length;w++){k.add_drawable(a(n[w],k,k))}}k.update_intro_div();var z;for(var w=0;w<k.drawables.length;w++){if(k.drawables[w].name===s){k.set_overview(k.drawables[w]);break}}if(p){var x;for(var w=0;w<p.length;w++){x=p[w];l.add_bookmark(x.position,x.annotation,m)}}k.has_changes=false});return k},init_keyboard_nav:function(j){$(document).keydown(function(k){if($(k.srcElement).is(":input")){return}switch(k.which){case 37:j.move_fraction(0.25);break;case 38:var l=Math.round(j.viewport_container.height()/15);j.viewport_container.scrollTop(j.viewport_container.scrollTop()-20);break;case 39:j.move_fraction(-0.25);break;case 40:var l=Math.round(j.viewport_container.height()/15);j.viewport_container.scrollTop(j.viewport_container.scrollTop()+20);break}})}});return{object_from_template:a,TracksterUI:f}}); \ No newline at end of file +define(["base","libs/underscore","viz/trackster/slotting","viz/trackster/painters","viz/trackster/tracks","viz/visualization"],function(g,c,h,e,b,d){var a=b.object_from_template;var f=g.Base.extend({initialize:function(j){this.baseURL=j},createButtonMenu:function(){var j=this,k=create_icon_buttons_menu([{icon_class:"plus-button",title:"Add tracks",on_click:function(){d.select_datasets(select_datasets_url,add_track_async_url,view.dbkey,function(l){c.each(l,function(m){view.add_drawable(a(m,view,view))})})}},{icon_class:"block--plus",title:"Add group",on_click:function(){view.add_drawable(new b.DrawableGroup(view,view,{name:"New Group"}))}},{icon_class:"bookmarks",title:"Bookmarks",on_click:function(){parent.force_right_panel(($("div#right").css("right")=="0px"?"hide":"show"))}},{icon_class:"globe",title:"Circster",on_click:function(){window.location=j.baseURL+"visualization/circster?id="+view.vis_id}},{icon_class:"disk--arrow",title:"Save",on_click:function(){show_modal("Saving...","progress");var l=[];$(".bookmark").each(function(){l.push({position:$(this).children(".position").text(),annotation:$(this).children(".annotation").text()})});var m=(view.overview_drawable?view.overview_drawable.name:null),n={view:view.to_dict(),viewport:{chrom:view.chrom,start:view.low,end:view.high,overview:m},bookmarks:l};$.ajax({url:galaxy_paths.get("visualization_url"),type:"POST",dataType:"json",data:{id:view.vis_id,title:view.name,dbkey:view.dbkey,type:"trackster",vis_json:JSON.stringify(n)}}).success(function(o){hide_modal();view.vis_id=o.vis_id;view.has_changes=false;window.history.pushState({},"",o.url+window.location.hash)}).error(function(){show_modal("Could Not Save","Could not save visualization. Please try again later.",{Close:hide_modal})})}},{icon_class:"cross-circle",title:"Close",on_click:function(){window.location=j.baseURL+"visualization/list"}}],{tooltip_config:{placement:"bottom"}});this.buttonMenu=k;return k},add_bookmarks:function(){var j=this,k=this.baseURL;show_modal("Select dataset for new bookmarks","progress");$.ajax({url:this.baseURL+"/visualization/list_histories",data:{"f-dbkey":view.dbkey},error:function(){alert("Grid failed")},success:function(l){show_modal("Select dataset for new bookmarks",l,{Cancel:function(){hide_modal()},Insert:function(){$("input[name=id]:checked,input[name=ldda_ids]:checked").first().each(function(){var m,n=$(this).val();if($(this).attr("name")==="id"){m={hda_id:n}}else{m={ldda_id:n}}$.ajax({url:this.baseURL+"/visualization/bookmarks_from_dataset",data:m,dataType:"json"}).then(function(o){for(i=0;i<o.data.length;i++){var p=o.data[i];j.add_bookmark(p[0],p[1])}})});hide_modal()}})}})},add_bookmark:function(n,l,j){var p=$("#bookmarks-container"),r=$("<div/>").addClass("bookmark").appendTo(p);var s=$("<div/>").addClass("position").appendTo(r),o=$("<a href=''/>").text(n).appendTo(s).click(function(){view.go_to(n);return false}),m=$("<div/>").text(l).appendTo(r);if(j){var q=$("<div/>").addClass("delete-icon-container").prependTo(r).click(function(){r.slideUp("fast");r.remove();view.has_changes=true;return false}),k=$("<a href=''/>").addClass("icon-button delete").appendTo(q);m.make_text_editable({num_rows:3,use_textarea:true,help_text:"Edit bookmark note"}).addClass("annotation")}view.has_changes=true;return r},create_visualization:function(o,j,n,p,m){var l=this,k=new b.View(o);k.editor=true;$.when(k.load_chroms_deferred).then(function(){if(j){var y=j.chrom,q=j.start,v=j.end,s=j.overview;if(y&&(q!==undefined)&&v){k.change_chrom(y,q,v)}}if(n){var t,r,u;for(var w=0;w<n.length;w++){k.add_drawable(a(n[w],k,k))}}k.update_intro_div();var z;for(var w=0;w<k.drawables.length;w++){if(k.drawables[w].name===s){k.set_overview(k.drawables[w]);break}}if(p){var x;for(var w=0;w<p.length;w++){x=p[w];l.add_bookmark(x.position,x.annotation,m)}}k.has_changes=false});return k},init_keyboard_nav:function(j){$(document).keydown(function(k){if($(k.srcElement).is(":input")){return}switch(k.which){case 37:j.move_fraction(0.25);break;case 38:var l=Math.round(j.viewport_container.height()/15);j.viewport_container.scrollTop(j.viewport_container.scrollTop()-20);break;case 39:j.move_fraction(-0.25);break;case 40:var l=Math.round(j.viewport_container.height()/15);j.viewport_container.scrollTop(j.viewport_container.scrollTop()+20);break}})}});return{object_from_template:a,TracksterUI:f}}); \ No newline at end of file diff -r 043012c62cfca6a30694445d47790726736c7032 -r d2c998e06f0ef7b117bf2e05150bbed877d5dcb3 static/scripts/packed/viz/visualization.js --- a/static/scripts/packed/viz/visualization.js +++ b/static/scripts/packed/viz/visualization.js @@ -1,1 +1,1 @@ -define(["libs/underscore","mvc/data","viz/trackster/util","utils/config"],function(s,i,l,p){var a=function(u,x,v,w){$.ajax({url:u,data:(v?{"f-dbkey":v}:{}),error:function(){alert("Grid failed")},success:function(y){show_modal("Select datasets for new tracks",y,{Cancel:function(){hide_modal()},Add:function(){var z=[];$("input[name=id]:checked,input[name=ldda_ids]:checked").each(function(){var A={data_type:"track_config",hda_ldda:"hda"},B=$(this).val();if($(this).attr("name")!=="id"){A.hda_ldda="ldda"}z[z.length]=$.ajax({url:x+"/"+B,data:A,dataType:"json"})});$.when.apply($,z).then(function(){var A=(arguments[0] instanceof Array?$.map(arguments,function(B){return B[0]}):[arguments[0]]);w(A)});hide_modal()}})}})};var j=function(u){return("isResolved" in u)};var f=function(u){this.default_font=u!==undefined?u:"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")};s.extend(f.prototype,{load_pattern:function(u,y){var v=this.patterns,w=this.dummy_context,x=new Image();x.src=galaxy_paths.attributes.image_path+y;x.onload=function(){v[u]=w.createPattern(x,"repeat")}},get_pattern:function(u){return this.patterns[u]},new_canvas:function(){var u=$("<canvas/>")[0];if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(u)}u.manager=this;return u}});var q=Backbone.Model.extend({defaults:{num_elements:20,obj_cache:null,key_ary:null},initialize:function(u){this.clear()},get_elt:function(v){var w=this.attributes.obj_cache,x=this.attributes.key_ary,u=x.indexOf(v);if(u!==-1){if(w[v].stale){x.splice(u,1);delete w[v]}else{this.move_key_to_end(v,u)}}return w[v]},set_elt:function(v,x){var y=this.attributes.obj_cache,z=this.attributes.key_ary,w=this.attributes.num_elements;if(!y[v]){if(z.length>=w){var u=z.shift();delete y[u]}z.push(v)}y[v]=x;return x},move_key_to_end:function(v,u){this.attributes.key_ary.splice(u,1);this.attributes.key_ary.push(v)},clear:function(){this.attributes.obj_cache={};this.attributes.key_ary=[]},size:function(){return this.attributes.key_ary.length}});var d=q.extend({defaults:s.extend({},q.prototype.defaults,{dataset:null,init_data:null,filters_manager:null,data_type:"data",data_mode_compatible:function(u,v){return true},can_subset:function(u){return false}}),initialize:function(u){q.prototype.initialize.call(this);var v=this.get("init_data");if(v){this.add_data(v)}},add_data:function(u){if(this.get("num_elements")<u.length){this.set("num_elements",u.length)}var v=this;s.each(u,function(w){v.set_data(w.region,w)})},data_is_ready:function(){var x=this.get("dataset"),w=$.Deferred(),u=(this.get("data_type")=="raw_data"?"state":this.get("data_type")=="data"?"converted_datasets_state":"error"),v=new l.ServerStateDeferred({ajax_settings:{url:this.get("dataset").url(),data:{hda_ldda:x.get("hda_ldda"),data_type:u},dataType:"json"},interval:5000,success_fn:function(y){return y!=="pending"}});$.when(v.go()).then(function(y){w.resolve(y==="ok"||y==="data")});return w},search_features:function(u){var v=this.get("dataset"),w={query:u,hda_ldda:v.get("hda_ldda"),data_type:"features"};return $.getJSON(v.url(),w)},load_data:function(C,B,v,A){var y=this.get("dataset"),x={data_type:this.get("data_type"),chrom:C.get("chrom"),low:C.get("start"),high:C.get("end"),mode:B,resolution:v,hda_ldda:y.get("hda_ldda")};$.extend(x,A);var E=this.get("filters_manager");if(E){var F=[];var u=E.filters;for(var z=0;z<u.length;z++){F.push(u[z].name)}x.filter_cols=JSON.stringify(F)}var w=this,D=$.getJSON(y.url(),x,function(G){w.set_data(C,G)});this.set_data(C,D);return D},get_data:function(A,z,w,y){var B=this.get_elt(A);if(B&&(j(B)||this.get("data_mode_compatible")(B,z))){return B}var C=this.get("key_ary"),v=this.get("obj_cache"),D,u;for(var x=0;x<C.length;x++){D=C[x];u=new g({from_str:D});if(u.contains(A)){B=v[D];if(j(B)||(this.get("data_mode_compatible")(B,z)&&this.get("can_subset")(B))){this.move_key_to_end(D,x);return B}}}return this.load_data(A,z,w,y)},set_data:function(v,u){this.set_elt(v,u)},DEEP_DATA_REQ:"deep",BROAD_DATA_REQ:"breadth",get_more_data:function(C,B,x,A,y){var E=this._mark_stale(C);if(!(E&&this.get("data_mode_compatible")(E,B))){console.log("ERROR: problem with getting more data: current data is not compatible");return}var w=C.get("start");if(y===this.DEEP_DATA_REQ){$.extend(A,{start_val:E.data.length+1})}else{if(y===this.BROAD_DATA_REQ){w=(E.max_high?E.max_high:E.data[E.data.length-1][2])+1}}var D=C.copy().set("start",w);var v=this,z=this.load_data(D,B,x,A),u=$.Deferred();this.set_data(C,u);$.when(z).then(function(F){if(F.data){F.data=E.data.concat(F.data);if(F.max_low){F.max_low=E.max_low}if(F.message){F.message=F.message.replace(/[0-9]+/,F.data.length)}}v.set_data(C,F);u.resolve(F)});return u},get_more_detailed_data:function(x,z,v,y,w){var u=this._mark_stale(x);if(!u){console.log("ERROR getting more detailed data: no current data");return}if(!w){w={}}if(u.dataset_type==="bigwig"){w.num_samples=u.data.length*y}else{if(u.dataset_type==="summary_tree"){w.level=Math.min(u.level-1,2)}}return this.load_data(x,z,v,w)},_mark_stale:function(v){var u=this.get_elt(v);if(!u){console.log("ERROR: no data to mark as stale: ",this.get("dataset"),v.toString())}u.stale=true;return u},get_genome_wide_data:function(u){var w=this,y=true,x=s.map(u.get("chroms_info").chrom_info,function(A){var z=w.get_elt(new g({chrom:A.chrom,start:0,end:A.len}));if(!z){y=false}return z});if(y){return x}var v=$.Deferred();$.getJSON(this.get("dataset").url(),{data_type:"genome_data"},function(z){w.add_data(z.data);v.resolve(z.data)});return v},get_elt:function(u){return q.prototype.get_elt.call(this,u.toString())},set_elt:function(v,u){return q.prototype.set_elt.call(this,v.toString(),u)}});var n=d.extend({initialize:function(u){var v=new Backbone.Model();v.urlRoot=u.data_url;this.set("dataset",v)},load_data:function(w,x,u,v){if(u>1){return{data:null}}return d.prototype.load_data.call(this,w,x,u,v)}});var c=Backbone.Model.extend({defaults:{name:null,key:null,chroms_info:null},initialize:function(u){this.id=u.dbkey},get_chroms_info:function(){return this.attributes.chroms_info.chrom_info},get_chrom_region:function(u){var v=s.find(this.get_chroms_info(),function(w){return w.chrom==u});return new g({chrom:v.chrom,end:v.len})}});var g=Backbone.RelationalModel.extend({defaults:{chrom:null,start:0,end:0,DIF_CHROMS:1000,BEFORE:1001,CONTAINS:1002,OVERLAP_START:1003,OVERLAP_END:1004,CONTAINED_BY:1005,AFTER:1006},initialize:function(v){if(v.from_str){var x=v.from_str.split(":"),w=x[0],u=x[1].split("-");this.set({chrom:w,start:parseInt(u[0],10),end:parseInt(u[1],10)})}},copy:function(){return new g({chrom:this.get("chrom"),start:this.get("start"),end:this.get("end")})},length:function(){return this.get("end")-this.get("start")},toString:function(){return this.get("chrom")+":"+this.get("start")+"-"+this.get("end")},toJSON:function(){return{chrom:this.get("chrom"),start:this.get("start"),end:this.get("end")}},compute_overlap:function(B){var v=this.get("chrom"),A=B.get("chrom"),z=this.get("start"),x=B.get("start"),y=this.get("end"),w=B.get("end"),u;if(v&&A&&v!==A){return this.get("DIF_CHROMS")}if(z<x){if(y<x){u=this.get("BEFORE")}else{if(y<=w){u=this.get("OVERLAP_START")}else{u=this.get("CONTAINS")}}}else{if(z>w){u=this.get("AFTER")}else{if(y<=w){u=this.get("CONTAINED_BY")}else{u=this.get("OVERLAP_END")}}}return u},contains:function(u){return this.compute_overlap(u)===this.get("CONTAINS")},overlaps:function(u){return s.intersection([this.compute_overlap(u)],[this.get("DIF_CHROMS"),this.get("BEFORE"),this.get("AFTER")]).length===0}});var m=Backbone.Collection.extend({model:g});var e=Backbone.RelationalModel.extend({defaults:{region:null,note:""},relations:[{type:Backbone.HasOne,key:"region",relatedModel:g}]});var r=Backbone.Collection.extend({model:e});var t=i.Dataset.extend({initialize:function(u){this.set("id",u.dataset_id);this.set("settings",p.ConfigSettingCollection.from_config_dict(u.prefs));var v=this.get("preloaded_data");if(v){v=v.data}else{v=[]}this.set("data_manager",new d({dataset:this,init_data:v}))}});var o=Backbone.RelationalModel.extend({defaults:{title:"",type:""},url:function(){return galaxy_paths.get("visualization_url")},save:function(){return $.ajax({url:this.url(),type:"POST",dataType:"json",data:{vis_json:JSON.stringify(this)}})}});var k=o.extend({defaults:s.extend({},o.prototype.defaults,{dbkey:"",tracks:null,bookmarks:null,viewport:null}),relations:[{type:Backbone.HasMany,key:"tracks",relatedModel:t}],add_tracks:function(u){this.get("tracks").add(u)}});var b=Backbone.Model.extend({});var h=Backbone.Router.extend({initialize:function(v){this.view=v.view;this.route(/([\w]+)$/,"change_location");this.route(/([\w]+\:[\d,]+-[\d,]+)$/,"change_location");var u=this;u.view.on("navigate",function(w){u.navigate(w)})},change_location:function(u){this.view.go_to(u)}});return{BackboneTrack:t,BrowserBookmark:e,BrowserBookmarkCollection:r,Cache:q,CanvasManager:f,Genome:c,GenomeDataManager:d,GenomeRegion:g,GenomeRegionCollection:m,GenomeVisualization:k,ReferenceTrackDataManager:n,TrackBrowserRouter:h,TrackConfig:b,Visualization:o,select_datasets:a}}); \ No newline at end of file +define(["libs/underscore","mvc/data","viz/trackster/util","utils/config"],function(s,i,l,p){var a=function(u,x,v,w){$.ajax({url:u,data:(v?{"f-dbkey":v}:{}),error:function(){alert("Grid failed")},success:function(y){show_modal("Select datasets for new tracks",y,{Cancel:function(){hide_modal()},Add:function(){var z=[];$("input[name=id]:checked,input[name=ldda_ids]:checked").each(function(){var A={data_type:"track_config",hda_ldda:"hda"},B=$(this).val();if($(this).attr("name")!=="id"){A.hda_ldda="ldda"}z[z.length]=$.ajax({url:x+"/"+B,data:A,dataType:"json"})});$.when.apply($,z).then(function(){var A=(arguments[0] instanceof Array?$.map(arguments,function(B){return B[0]}):[arguments[0]]);w(A)});hide_modal()}})}})};var j=function(u){return("isResolved" in u)};var f=function(u){this.default_font=u!==undefined?u:"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")};s.extend(f.prototype,{load_pattern:function(u,y){var v=this.patterns,w=this.dummy_context,x=new Image();x.src=galaxy_paths.attributes.image_path+y;x.onload=function(){v[u]=w.createPattern(x,"repeat")}},get_pattern:function(u){return this.patterns[u]},new_canvas:function(){var u=$("<canvas/>")[0];if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(u)}u.manager=this;return u}});var q=Backbone.Model.extend({defaults:{num_elements:20,obj_cache:null,key_ary:null},initialize:function(u){this.clear()},get_elt:function(v){var w=this.attributes.obj_cache,x=this.attributes.key_ary,u=x.indexOf(v);if(u!==-1){if(w[v].stale){x.splice(u,1);delete w[v]}else{this.move_key_to_end(v,u)}}return w[v]},set_elt:function(v,x){var y=this.attributes.obj_cache,z=this.attributes.key_ary,w=this.attributes.num_elements;if(!y[v]){if(z.length>=w){var u=z.shift();delete y[u]}z.push(v)}y[v]=x;return x},move_key_to_end:function(v,u){this.attributes.key_ary.splice(u,1);this.attributes.key_ary.push(v)},clear:function(){this.attributes.obj_cache={};this.attributes.key_ary=[]},size:function(){return this.attributes.key_ary.length}});var d=q.extend({defaults:s.extend({},q.prototype.defaults,{dataset:null,init_data:null,filters_manager:null,data_type:"data",data_mode_compatible:function(u,v){return true},can_subset:function(u){return false}}),initialize:function(u){q.prototype.initialize.call(this);var v=this.get("init_data");if(v){this.add_data(v)}},add_data:function(u){if(this.get("num_elements")<u.length){this.set("num_elements",u.length)}var v=this;s.each(u,function(w){v.set_data(w.region,w)})},data_is_ready:function(){var x=this.get("dataset"),w=$.Deferred(),u=(this.get("data_type")=="raw_data"?"state":this.get("data_type")=="data"?"converted_datasets_state":"error"),v=new l.ServerStateDeferred({ajax_settings:{url:this.get("dataset").url(),data:{hda_ldda:x.get("hda_ldda"),data_type:u},dataType:"json"},interval:5000,success_fn:function(y){return y!=="pending"}});$.when(v.go()).then(function(y){w.resolve(y==="ok"||y==="data")});return w},search_features:function(u){var v=this.get("dataset"),w={query:u,hda_ldda:v.get("hda_ldda"),data_type:"features"};return $.getJSON(v.url(),w)},load_data:function(C,B,v,A){var y=this.get("dataset"),x={data_type:this.get("data_type"),chrom:C.get("chrom"),low:C.get("start"),high:C.get("end"),mode:B,resolution:v,hda_ldda:y.get("hda_ldda")};$.extend(x,A);var E=this.get("filters_manager");if(E){var F=[];var u=E.filters;for(var z=0;z<u.length;z++){F.push(u[z].name)}x.filter_cols=JSON.stringify(F)}var w=this,D=$.getJSON(y.url(),x,function(G){w.set_data(C,G)});this.set_data(C,D);return D},get_data:function(A,z,w,y){var B=this.get_elt(A);if(B&&(j(B)||this.get("data_mode_compatible")(B,z))){return B}var C=this.get("key_ary"),v=this.get("obj_cache"),D,u;for(var x=0;x<C.length;x++){D=C[x];u=new g({from_str:D});if(u.contains(A)){B=v[D];if(j(B)||(this.get("data_mode_compatible")(B,z)&&this.get("can_subset")(B))){this.move_key_to_end(D,x);return B}}}return this.load_data(A,z,w,y)},set_data:function(v,u){this.set_elt(v,u)},DEEP_DATA_REQ:"deep",BROAD_DATA_REQ:"breadth",get_more_data:function(C,B,x,A,y){var E=this._mark_stale(C);if(!(E&&this.get("data_mode_compatible")(E,B))){console.log("ERROR: problem with getting more data: current data is not compatible");return}var w=C.get("start");if(y===this.DEEP_DATA_REQ){$.extend(A,{start_val:E.data.length+1})}else{if(y===this.BROAD_DATA_REQ){w=(E.max_high?E.max_high:E.data[E.data.length-1][2])+1}}var D=C.copy().set("start",w);var v=this,z=this.load_data(D,B,x,A),u=$.Deferred();this.set_data(C,u);$.when(z).then(function(F){if(F.data){F.data=E.data.concat(F.data);if(F.max_low){F.max_low=E.max_low}if(F.message){F.message=F.message.replace(/[0-9]+/,F.data.length)}}v.set_data(C,F);u.resolve(F)});return u},can_get_more_detailed_data:function(v){var u=this.get_elt(v);return(u.dataset_type==="bigwig"&&u.data.length<8000)},get_more_detailed_data:function(x,z,v,y,w){var u=this._mark_stale(x);if(!u){console.log("ERROR getting more detailed data: no current data");return}if(!w){w={}}if(u.dataset_type==="bigwig"){w.num_samples=1000*y}else{if(u.dataset_type==="summary_tree"){w.level=Math.min(u.level-1,2)}}return this.load_data(x,z,v,w)},_mark_stale:function(v){var u=this.get_elt(v);if(!u){console.log("ERROR: no data to mark as stale: ",this.get("dataset"),v.toString())}u.stale=true;return u},get_genome_wide_data:function(u){var w=this,y=true,x=s.map(u.get("chroms_info").chrom_info,function(A){var z=w.get_elt(new g({chrom:A.chrom,start:0,end:A.len}));if(!z){y=false}return z});if(y){return x}var v=$.Deferred();$.getJSON(this.get("dataset").url(),{data_type:"genome_data"},function(z){w.add_data(z.data);v.resolve(z.data)});return v},get_elt:function(u){return q.prototype.get_elt.call(this,u.toString())},set_elt:function(v,u){return q.prototype.set_elt.call(this,v.toString(),u)}});var n=d.extend({initialize:function(u){var v=new Backbone.Model();v.urlRoot=u.data_url;this.set("dataset",v)},load_data:function(w,x,u,v){if(u>1){return{data:null}}return d.prototype.load_data.call(this,w,x,u,v)}});var c=Backbone.Model.extend({defaults:{name:null,key:null,chroms_info:null},initialize:function(u){this.id=u.dbkey},get_chroms_info:function(){return this.attributes.chroms_info.chrom_info},get_chrom_region:function(u){var v=s.find(this.get_chroms_info(),function(w){return w.chrom==u});return new g({chrom:v.chrom,end:v.len})}});var g=Backbone.RelationalModel.extend({defaults:{chrom:null,start:0,end:0,DIF_CHROMS:1000,BEFORE:1001,CONTAINS:1002,OVERLAP_START:1003,OVERLAP_END:1004,CONTAINED_BY:1005,AFTER:1006},initialize:function(v){if(v.from_str){var x=v.from_str.split(":"),w=x[0],u=x[1].split("-");this.set({chrom:w,start:parseInt(u[0],10),end:parseInt(u[1],10)})}},copy:function(){return new g({chrom:this.get("chrom"),start:this.get("start"),end:this.get("end")})},length:function(){return this.get("end")-this.get("start")},toString:function(){return this.get("chrom")+":"+this.get("start")+"-"+this.get("end")},toJSON:function(){return{chrom:this.get("chrom"),start:this.get("start"),end:this.get("end")}},compute_overlap:function(B){var v=this.get("chrom"),A=B.get("chrom"),z=this.get("start"),x=B.get("start"),y=this.get("end"),w=B.get("end"),u;if(v&&A&&v!==A){return this.get("DIF_CHROMS")}if(z<x){if(y<x){u=this.get("BEFORE")}else{if(y<=w){u=this.get("OVERLAP_START")}else{u=this.get("CONTAINS")}}}else{if(z>w){u=this.get("AFTER")}else{if(y<=w){u=this.get("CONTAINED_BY")}else{u=this.get("OVERLAP_END")}}}return u},contains:function(u){return this.compute_overlap(u)===this.get("CONTAINS")},overlaps:function(u){return s.intersection([this.compute_overlap(u)],[this.get("DIF_CHROMS"),this.get("BEFORE"),this.get("AFTER")]).length===0}});var m=Backbone.Collection.extend({model:g});var e=Backbone.RelationalModel.extend({defaults:{region:null,note:""},relations:[{type:Backbone.HasOne,key:"region",relatedModel:g}]});var r=Backbone.Collection.extend({model:e});var t=i.Dataset.extend({initialize:function(u){this.set("id",u.dataset_id);this.set("config",p.ConfigSettingCollection.from_config_dict(u.prefs));this.get("config").add([{key:"name",value:this.get("name")},{key:"color"}]);var v=this.get("preloaded_data");if(v){v=v.data}else{v=[]}this.set("data_manager",new d({dataset:this,init_data:v}))}});var o=Backbone.RelationalModel.extend({defaults:{title:"",type:""},url:galaxy_paths.get("visualization_url"),save:function(){return $.ajax({url:this.url(),type:"POST",dataType:"json",data:{vis_json:JSON.stringify(this)}})}});var k=o.extend({defaults:s.extend({},o.prototype.defaults,{dbkey:"",tracks:null,bookmarks:null,viewport:null}),relations:[{type:Backbone.HasMany,key:"tracks",relatedModel:t}],add_tracks:function(u){this.get("tracks").add(u)}});var b=Backbone.Model.extend({});var h=Backbone.Router.extend({initialize:function(v){this.view=v.view;this.route(/([\w]+)$/,"change_location");this.route(/([\w]+\:[\d,]+-[\d,]+)$/,"change_location");var u=this;u.view.on("navigate",function(w){u.navigate(w)})},change_location:function(u){this.view.go_to(u)}});return{BackboneTrack:t,BrowserBookmark:e,BrowserBookmarkCollection:r,Cache:q,CanvasManager:f,Genome:c,GenomeDataManager:d,GenomeRegion:g,GenomeRegionCollection:m,GenomeVisualization:k,ReferenceTrackDataManager:n,TrackBrowserRouter:h,TrackConfig:b,Visualization:o,select_datasets:a}}); \ No newline at end of file Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.