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
April 2011
- 1 participants
- 112 discussions
commit/galaxy-central: james_taylor: trackster: fix read track drawing offsets for all modes
by Bitbucket 04 Apr '11
by Bitbucket 04 Apr '11
04 Apr '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/6d80641672e5/
changeset: r5338:6d80641672e5
user: james_taylor
date: 2011-04-04 19:40:09
summary: trackster: fix read track drawing offsets for all modes
affected #: 1 file (484 bytes)
--- a/static/scripts/trackster.js Mon Apr 04 12:55:33 2011 -0400
+++ b/static/scripts/trackster.js Mon Apr 04 13:40:09 2011 -0400
@@ -2779,7 +2779,6 @@
var required_height = y_scale = this.get_row_height(), mode = this.mode;
// If using a packing mode, need to multiply by the number of slots used
if (mode === "no_detail" || mode === "Squish" || mode === "Pack") {
- // Calculate new slots incrementally for this new chunk of data and update height if necessary.
required_height = rows_required * y_scale;
}
// Pad bottom by half a row, at least 5 px
@@ -2807,7 +2806,7 @@
// Slot valid only if features are slotted and this feature is slotted;
// feature may not be due to lack of space.
slot = (slots && slots[feature_uid] !== undefined ? slots[feature_uid] : null);
-
+
// Draw feature if there's overlap and mode is dense or feature is slotted (as it must be for all non-dense modes).
if ( ( feature_start < view_end && feature_end > view_start ) && (this.mode == "Dense" || slot !== null)) {
this.draw_element(ctx, this.mode, feature, slot, view_start, view_end, w_scale, y_scale,
@@ -2843,10 +2842,7 @@
*/
get_row_height: function() {
var mode = this.mode, y_scale;
- if (mode === "summary_tree") {
- // No scale needed.
- }
- if (mode === "Dense") {
+ if (mode === "Dense") {
y_scale = DENSE_TRACK_HEIGHT;
}
else if (mode === "no_detail") {
@@ -3055,7 +3051,7 @@
if (mode !== "Dense" && feature_name !== undefined && feature_start > tile_low) {
// Draw label
ctx.fillStyle = label_color;
- if (tile_index === 0 && f_start - ctx.measureText(feature_name).width < 0) {
+ if (tile_low === 0 && f_start - ctx.measureText(feature_name).width < 0) {
ctx.textAlign = "left";
ctx.fillText(feature_name, f_end + 2 + left_offset, y_center + 8);
} else {
@@ -3125,9 +3121,6 @@
*/
get_row_height: function() {
var y_scale, mode = this.mode;
- if (mode === "summary_tree") {
- // No scale needed.
- }
if (mode === "Dense") {
y_scale = DENSE_TRACK_HEIGHT;
}
@@ -3213,10 +3206,7 @@
} else {
ctx.fillStyle = this.prefs.block_color;
// TODO: This is a pretty hack-ish way to fill rectangle based on mode.
- ctx.fillRect(s_start,
- y_center + (this.mode !== "Dense" ? 4 : 5),
- s_end - s_start,
- (mode !== "Dense" ? SQUISH_FEATURE_HEIGHT : DENSE_FEATURE_HEIGHT) );
+ ctx.fillRect(s_start, y_center + 4, s_end - s_start, SQUISH_FEATURE_HEIGHT);
}
}
seq_offset += cig_len;
@@ -3343,7 +3333,7 @@
feature_name = feature[3],
f_start = Math.floor( Math.max(0, (feature_start - tile_low) * w_scale) ),
f_end = Math.ceil( Math.min(width, Math.max(0, (feature_end - tile_low) * w_scale)) ),
- y_center = (mode === "Dense" ? 1 : (1 + slot)) * y_scale,
+ y_center = (mode === "Dense" ? 0 : (0 + slot)) * y_scale,
block_color = this.prefs.block_color,
label_color = this.prefs.label_color,
// Left-gap for label text since we align chrom text to the position tick.
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/e12237461b3e/
changeset: r5337:e12237461b3e
user: kanwei
date: 2011-04-04 18:55:33
summary: BLAST test changes
affected #: 4 files (383 bytes)
--- a/test-data/blastp_rhodopsin_vs_four_human.tabular Sun Apr 03 12:47:39 2011 -0400
+++ b/test-data/blastp_rhodopsin_vs_four_human.tabular Mon Apr 04 12:55:33 2011 -0400
@@ -1,6 +1,6 @@
-gi|57163783|ref|NP_001009242.1| Subject_4 96.55 348 12 0 1 348 1 348 0.0 679
-gi|3024260|sp|P56514.1|OPSD_BUFBU Subject_4 83.33 354 53 2 1 354 1 348 6e-178 605
-gi|283855846|gb|ADB45242.1| Subject_4 94.82 328 17 0 1 328 11 338 0.0 630
-gi|283855823|gb|ADB45229.1| Subject_4 94.82 328 17 0 1 328 11 338 0.0 630
-gi|223523|prf||0811197A Subject_4 93.10 348 23 1 1 347 1 348 0.0 651
-gi|12583665|dbj|BAB21486.1| Subject_4 81.09 349 65 1 1 349 1 348 2e-172 587
+gi|57163783|ref|NP_001009242.1| sp|P08100|OPSD_HUMAN 96.55 348 12 0 1 348 1 348 0.0 679
+gi|3024260|sp|P56514.1|OPSD_BUFBU sp|P08100|OPSD_HUMAN 83.33 354 53 2 1 354 1 348 6e-178 605
+gi|283855846|gb|ADB45242.1| sp|P08100|OPSD_HUMAN 94.82 328 17 0 1 328 11 338 0.0 630
+gi|283855823|gb|ADB45229.1| sp|P08100|OPSD_HUMAN 94.82 328 17 0 1 328 11 338 0.0 630
+gi|223523|prf||0811197A sp|P08100|OPSD_HUMAN 93.10 348 23 1 1 347 1 348 0.0 651
+gi|12583665|dbj|BAB21486.1| sp|P08100|OPSD_HUMAN 81.09 349 65 1 1 349 1 348 2e-172 587
--- a/test-data/tblastn_four_human_vs_rhodopsin.tabular Sun Apr 03 12:47:39 2011 -0400
+++ b/test-data/tblastn_four_human_vs_rhodopsin.tabular Mon Apr 04 12:55:33 2011 -0400
@@ -1,10 +1,10 @@
-sp|P08100|OPSD_HUMAN Subject_1 96.55 348 12 0 1 348 1 1044 0.0 732
-sp|P08100|OPSD_HUMAN Subject_2 84.80 342 51 1 1 341 42 1067 0.0 646
-sp|P08100|OPSD_HUMAN Subject_3 93.24 74 5 0 239 312 3147 3368 1e-72 151
-sp|P08100|OPSD_HUMAN Subject_3 91.53 59 5 0 177 235 2855 3031 1e-72 126
-sp|P08100|OPSD_HUMAN Subject_3 96.40 111 4 0 11 121 1 333 1e-64 229
-sp|P08100|OPSD_HUMAN Subject_3 93.22 59 4 0 119 177 1404 1580 1e-32 122
-sp|P08100|OPSD_HUMAN Subject_3 88.46 26 3 0 312 337 4222 4299 6e-13 57.7
-sp|P08100|OPSD_HUMAN Subject_4 95.09 326 16 0 11 336 1 978 0.0 658
-sp|P08100|OPSD_HUMAN Subject_5 93.39 348 23 0 1 348 1 1044 0.0 711
-sp|P08100|OPSD_HUMAN Subject_6 82.16 342 60 1 1 341 23 1048 0.0 626
+sp|P08100|OPSD_HUMAN gi|57163782|ref|NM_001009242.1| 96.55 348 12 0 1 348 1 1044 0.0 732
+sp|P08100|OPSD_HUMAN gi|2734705|gb|U59921.1|BBU59921 84.80 342 51 1 1 341 42 1067 0.0 646
+sp|P08100|OPSD_HUMAN gi|283855845|gb|GQ290303.1| 93.24 74 5 0 239 312 3147 3368 1e-72 151
+sp|P08100|OPSD_HUMAN gi|283855845|gb|GQ290303.1| 91.53 59 5 0 177 235 2855 3031 1e-72 126
+sp|P08100|OPSD_HUMAN gi|283855845|gb|GQ290303.1| 96.40 111 4 0 11 121 1 333 1e-64 229
+sp|P08100|OPSD_HUMAN gi|283855845|gb|GQ290303.1| 93.22 59 4 0 119 177 1404 1580 1e-32 122
+sp|P08100|OPSD_HUMAN gi|283855845|gb|GQ290303.1| 88.46 26 3 0 312 337 4222 4299 6e-13 57.7
+sp|P08100|OPSD_HUMAN gi|283855822|gb|GQ290312.1| 95.09 326 16 0 11 336 1 978 0.0 658
+sp|P08100|OPSD_HUMAN gi|18148870|dbj|AB062417.1| 93.39 348 23 0 1 348 1 1044 0.0 711
+sp|P08100|OPSD_HUMAN gi|12583664|dbj|AB043817.1| 82.16 342 60 1 1 341 23 1048 0.0 626
--- a/tools/ncbi_blast_plus/ncbi_blastp_wrapper.xml Sun Apr 03 12:47:39 2011 -0400
+++ b/tools/ncbi_blast_plus/ncbi_blastp_wrapper.xml Mon Apr 04 12:55:33 2011 -0400
@@ -133,6 +133,8 @@
<param name="subject" value="rhodopsin_proteins.fasta" ftype="fasta" /><param name="database" value="" /><param name="evalue_cutoff" value="1e-8" />
+ <param name="blast_type" value="blastp" />
+ <param name="out_format" value="6" /><param name="adv_opts_selector" value="advanced" /><param name="filter_query" value="True" /><param name="matrix" value="BLOSUM62" />
--- a/tools/ncbi_blast_plus/ncbi_tblastn_wrapper.xml Sun Apr 03 12:47:39 2011 -0400
+++ b/tools/ncbi_blast_plus/ncbi_tblastn_wrapper.xml Mon Apr 04 12:55:33 2011 -0400
@@ -138,7 +138,7 @@
<output name="output1" file="tblastn_four_human_vs_rhodopsin.tabular" ftype="tabular" /></test><test>
- <!-- Same as above, but parse deflines -->
+ <!-- Same as above, but parse deflines - on BLAST 2.2.25+ makes no difference --><param name="query" value="four_human_proteins.fasta" ftype="fasta" /><param name="db_opts_selector" value="file" /><param name="subject" value="rhodopsin_nucs.fasta" ftype="fasta" />
@@ -151,7 +151,7 @@
<param name="max_hits" value="0" /><param name="word_size" value="0" /><param name="parse_deflines" value="true" />
- <output name="output1" file="tblastn_four_human_vs_rhodopsin_parse_deflines.tabular" ftype="tabular" />
+ <output name="output1" file="tblastn_four_human_vs_rhodopsin.tabular" ftype="tabular" /></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
2 new changesets in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/7deb53694d98/
changeset: r5335:7deb53694d98
user: james_taylor
date: 2011-04-03 18:40:28
summary: trackster: typo
affected #: 1 file (0 bytes)
--- a/static/scripts/trackster.js Sat Apr 02 23:13:38 2011 -0400
+++ b/static/scripts/trackster.js Sun Apr 03 12:40:28 2011 -0400
@@ -2172,7 +2172,7 @@
if ( mode == "no_detail" ) {
mode = "reduced to feature spans";
} else if ( mode == "summary_tree" ) {
- mode = "reduced to foverage histogram";
+ mode = "reduced to coverage histogram";
}
this.mode_div.text( "Auto (" + mode + ")" );
}
http://bitbucket.org/galaxy/galaxy-central/changeset/086c9c2c52b9/
changeset: r5336:086c9c2c52b9
user: james_taylor
date: 2011-04-03 18:47:39
summary: trackster: some fixes for read tracks
affected #: 1 file (119 bytes)
--- a/static/scripts/trackster.js Sun Apr 03 12:40:28 2011 -0400
+++ b/static/scripts/trackster.js Sun Apr 03 12:47:39 2011 -0400
@@ -69,52 +69,6 @@
}
});
-/**
- * Draw a dashed line on a canvas using filled rectangles. This function is based on:
- * http://vetruvet.blogspot.com/2010/10/drawing-dashed-lines-on-html5-canvas.h…
- * However, that approach uses lines, which don't seem to render as well, so use
- * rectangles instead.
- */
-var dashedLine = function(ctx, x1, y1, x2, y2, dashLen) {
- if (dashLen === undefined) { dashLen = 4; }
- var dX = x2 - x1;
- var dY = y2 - y1;
- var dashes = Math.floor(Math.sqrt(dX * dX + dY * dY) / dashLen);
- var dashX = dX / dashes;
- var dashY = dY / dashes;
- var q;
-
- for (q = 0; q < dashes; q++, x1 += dashX, y1 += dashY) {
- if (q % 2 !== 0) {
- continue;
- }
- ctx.fillRect(x1, y1, dashLen, 1);
- }
-};
-
-/**
- * Draw an isosceles triangle that points down.
- */
-var drawDownwardEquilateralTriangle = function(ctx, down_vertex_x, down_vertex_y, side_len) {
- // Compute other two points of triangle.
- var
- x1 = down_vertex_x - side_len/2,
- x2 = down_vertex_x + side_len/2,
- y = down_vertex_y - Math.sqrt( side_len*3/2 );
-
- // Draw and fill.
- ctx.beginPath();
- ctx.moveTo(x1, y);
- ctx.lineTo(x2, y);
- ctx.lineTo(down_vertex_x, down_vertex_y);
- ctx.lineTo(x1, y);
-
- ctx.strokeStyle = this.fillStyle;
- ctx.fill();
- ctx.stroke();
- ctx.closePath();
-};
-
// ---- Web UI specific utilities ----
/**
@@ -1760,7 +1714,7 @@
$.when(track.data_cache.get_data(view.chrom, tile_low, tile_high, track.mode,
resolution, track.data_url_extra_params)).then(function(tile_data) {
// If sequence data needed, get that and draw. Otherwise draw.
- if (view.reference_track && w_scale > CHAR_WIDTH_PX) {
+ if (view.reference_track && w_scale > view.canvas_manager.char_width_px) {
$.when(view.reference_track.data_cache.get_data(view.chrom, tile_low, tile_high,
track.mode, resolution,
view.reference_track.data_url_extra_params)).then(function(seq_data) {
@@ -1959,7 +1913,7 @@
var track = this,
tile_length = DENSITY * resolution;
- if (w_scale > CHAR_WIDTH_PX) {
+ if (w_scale > this.view.canvas_manager.char_width_px) {
if (seq === null) {
track.content_div.css("height", "0px");
return;
@@ -2605,6 +2559,52 @@
var painters_module = function(require, exports){
/**
+ * Draw a dashed line on a canvas using filled rectangles. This function is based on:
+ * http://vetruvet.blogspot.com/2010/10/drawing-dashed-lines-on-html5-canvas.h…
+ * However, that approach uses lines, which don't seem to render as well, so use
+ * rectangles instead.
+ */
+var dashedLine = function(ctx, x1, y1, x2, y2, dashLen) {
+ if (dashLen === undefined) { dashLen = 4; }
+ var dX = x2 - x1;
+ var dY = y2 - y1;
+ var dashes = Math.floor(Math.sqrt(dX * dX + dY * dY) / dashLen);
+ var dashX = dX / dashes;
+ var dashY = dY / dashes;
+ var q;
+
+ for (q = 0; q < dashes; q++, x1 += dashX, y1 += dashY) {
+ if (q % 2 !== 0) {
+ continue;
+ }
+ ctx.fillRect(x1, y1, dashLen, 1);
+ }
+};
+
+/**
+ * Draw an isosceles triangle that points down.
+ */
+var drawDownwardEquilateralTriangle = function(ctx, down_vertex_x, down_vertex_y, side_len) {
+ // Compute other two points of triangle.
+ var
+ x1 = down_vertex_x - side_len/2,
+ x2 = down_vertex_x + side_len/2,
+ y = down_vertex_y - Math.sqrt( side_len*3/2 );
+
+ // Draw and fill.
+ ctx.beginPath();
+ ctx.moveTo(x1, y);
+ ctx.lineTo(x2, y);
+ ctx.lineTo(down_vertex_x, down_vertex_y);
+ ctx.lineTo(x1, y);
+
+ ctx.strokeStyle = this.fillStyle;
+ ctx.fill();
+ ctx.stroke();
+ ctx.closePath();
+};
+
+/**
* SummaryTreePainter, a histogram showing number of intervals in a region
*/
var SummaryTreePainter = function( data, delta, max, view_start, view_end, show_counts ) {
@@ -3152,14 +3152,15 @@
base_offset = 0,
seq_offset = 0,
gap = 0
- ref_seq = this.ref_seq;
+ ref_seq = this.ref_seq,
+ char_width_px = ctx.canvas.manager.char_width_px;
// Keep list of items that need to be drawn on top of initial drawing layer.
var draw_last = [];
// Gap is needed so that read is offset and hence first base can be drawn on read.
// TODO-FIX: using this gap offsets reads so that their start is not visually in sync with other tracks.
- if ((mode === "Pack" || this.mode === "Auto") && orig_seq !== undefined && w_scale > CHAR_WIDTH_PX) {
+ if ((mode === "Pack" || this.mode === "Auto") && orig_seq !== undefined && w_scale > char_width_px) {
gap = Math.round(w_scale/2);
}
if (!cigar) {
@@ -3256,7 +3257,7 @@
// Draw sequence.
// X center is offset + start - <half_sequence_length>
var x_center = s_start - (s_end - s_start)/2;
- if ( (mode === "Pack" || this.mode === "Auto") && orig_seq !== undefined && w_scale > CHAR_WIDTH_PX) {
+ if ( (mode === "Pack" || this.mode === "Auto") && orig_seq !== undefined && w_scale > char_width_px) {
// Draw sequence container.
ctx.fillStyle = "yellow";
ctx.fillRect(x_center - gap, y_center - 9, s_end - s_start, 9);
@@ -3292,7 +3293,7 @@
}
}
else {
- if ( (mode === "Pack" || this.mode === "Auto") && orig_seq !== undefined && w_scale > CHAR_WIDTH_PX) {
+ if ( (mode === "Pack" || this.mode === "Auto") && orig_seq !== undefined && w_scale > char_width_px) {
// Show insertions with a single number at the insertion point.
draw_last[draw_last.length] = {type: "text", data: [seq.length, insert_x_coord, y_center + 9]};
}
@@ -3349,7 +3350,7 @@
gap = 0;
// TODO: fix gap usage; also see note on gap in draw_read.
- if ((mode === "Pack" || this.mode === "Auto") && w_scale > CHAR_WIDTH_PX) {
+ if ((mode === "Pack" || this.mode === "Auto") && w_scale > ctx.canvas.manager.char_width_px) {
var gap = Math.round(w_scale/2);
}
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: james_taylor: trackster: tabs. why won't this editor respect my authority?
by Bitbucket 02 Apr '11
by Bitbucket 02 Apr '11
02 Apr '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/f13780c1674f/
changeset: r5334:f13780c1674f
user: james_taylor
date: 2011-04-03 05:13:38
summary: trackster: tabs. why won't this editor respect my authority?
affected #: 1 file (2.0 KB)
--- a/static/scripts/trackster.js Sat Apr 02 23:12:02 2011 -0400
+++ b/static/scripts/trackster.js Sat Apr 02 23:13:38 2011 -0400
@@ -46,26 +46,26 @@
extend( CanvasManager.prototype, {
load_pattern: function( key, path ) {
- var patterns = this.patterns,
- dummy_context = this.dummy_context,
- image = new Image();
- // FIXME: where does image_path come from? not in browser.mako...
- image.src = image_path + path;
- image.onload = function() {
- patterns[key] = dummy_context.createPattern( image, "repeat" );
- }
+ var patterns = this.patterns,
+ dummy_context = this.dummy_context,
+ image = new Image();
+ // FIXME: where does image_path come from? not in browser.mako...
+ image.src = image_path + path;
+ image.onload = function() {
+ patterns[key] = dummy_context.createPattern( image, "repeat" );
+ }
},
get_pattern: function( key ) {
- return this.patterns[key];
+ return this.patterns[key];
},
new_canvas: function() {
- var canvas = this.document.createElement("canvas");
- // If using excanvas in IE, we need to explicately attach the canvas
- // methods to the DOM element
- if (window.G_vmlCanvasManager) { G_vmlCanvasManager.initElement(canvas); }
- // Keep a reference back to the manager
- canvas.manager = this;
- return canvas;
+ var canvas = this.document.createElement("canvas");
+ // If using excanvas in IE, we need to explicately attach the canvas
+ // methods to the DOM element
+ if (window.G_vmlCanvasManager) { G_vmlCanvasManager.initElement(canvas); }
+ // Keep a reference back to the manager
+ canvas.manager = this;
+ return canvas;
}
});
@@ -291,8 +291,8 @@
// the data was "index" or "data." Also could slice the data so that
// only data points in request are returned.
//
-
- /* Disabling for now, more detailed data is never loaded for line tracks
+
+ /* Disabling for now, more detailed data is never loaded for line tracks
if (this.subset) {
var key, split_key, entry_low, entry_high, mode, entry;
for (var i = 0; i < this.key_ary.length; i++) {
@@ -312,13 +312,13 @@
}
}
}
- */
+ */
// Load data from server. The deferred is immediately saved until the
- // data is ready, it then replaces itself with the actual data
+ // data is ready, it then replaces itself with the actual data
entry = this.load_data(chrom, low, high, mode, resolution, extra_params);
- this.set_data( low, high, mode, entry );
- return entry
+ this.set_data( low, high, mode, entry );
+ return entry
},
set_data: function(low, high, mode, result) {
//console.log("set_data", low, high, mode, result);
@@ -1718,8 +1718,8 @@
var track = this;
// Put a 50ms delay on drawing so that if the user scrolls fast, we don't load extra data
var draw_and_show_tile = function(id, result, resolution, tile_index, parent_element, w_scale, seq_data) {
- // DEBUG: this is still called too many times when moving slowly,
- // console.log( "draw_and_show_tile", resolution, tile_index, w_scale );
+ // DEBUG: this is still called too many times when moving slowly,
+ // console.log( "draw_and_show_tile", resolution, tile_index, w_scale );
returned_tile = track.draw_tile(result, resolution, tile_index, parent_element, w_scale, seq_data)
// Wrap element in div for background
@@ -2111,7 +2111,7 @@
// Paint line onto full canvas
var ctx = canvas.getContext("2d");
var painter = new painters.LinePainter( result.data, tile_low, tile_low + tile_length,
- this.prefs.min_value, this.prefs.max_value, this.prefs.color, this.mode );
+ this.prefs.min_value, this.prefs.max_value, this.prefs.color, this.mode );
painter.draw( ctx, width, height );
return canvas;
@@ -2193,7 +2193,7 @@
inc_slots = this.inc_slots[level];
if (!inc_slots || (inc_slots.mode !== mode)) {
inc_slots = new (slotting.FeatureSlotter)( level, mode === "Pack", MAX_FEATURE_DEPTH, function ( x ) { return dummy_context.measureText( x ) } );
- inc_slots.mode = mode;
+ inc_slots.mode = mode;
this.inc_slots[level] = inc_slots;
}
@@ -2465,135 +2465,135 @@
*/
extend( exports.FeatureSlotter.prototype, {
slot_features: function( features ) {
- var w_scale = this.w_scale, inc_slots = this.slots, start_end_dct = this.start_end_dct,
- undone = [], slotted = [], highest_slot = 0, max_rows = this.max_rows;
-
- // If feature already exists in slots (from previously seen tiles), use the same slot,
- // otherwise if not seen, add to "undone" list for slot calculation.
+ var w_scale = this.w_scale, inc_slots = this.slots, start_end_dct = this.start_end_dct,
+ undone = [], slotted = [], highest_slot = 0, max_rows = this.max_rows;
+
+ // If feature already exists in slots (from previously seen tiles), use the same slot,
+ // otherwise if not seen, add to "undone" list for slot calculation.
- // TODO: Should calculate zoom tile index, which will improve performance
- // by only having to look at a smaller subset
- // if (this.start_end_dct[0] === undefined) { this.start_end_dct[0] = []; }
- for (var i = 0, len = features.length; i < len; i++) {
- var feature = features[i],
- feature_uid = feature[0];
- if (inc_slots[feature_uid] !== undefined) {
- highest_slot = Math.max(highest_slot, inc_slots[feature_uid]);
- slotted.push(inc_slots[feature_uid]);
- } else {
- undone.push(i);
- }
- }
-
- // Slot unslotted features.
-
- // Find the first slot such that current feature doesn't overlap any other features in that slot.
- // Returns -1 if no slot was found.
- var find_slot = function(f_start, f_end) {
- // TODO: Fix constants
- for (var slot_num = 0; slot_num <= max_rows; slot_num++) {
- var has_overlap = false,
- slot = start_end_dct[slot_num];
- if (slot !== undefined) {
- // Iterate through features already in slot to see if current feature will fit.
- for (var k = 0, k_len = slot.length; k < k_len; k++) {
- var s_e = slot[k];
- if (f_end > s_e[0] && f_start < s_e[1]) {
- // There is overlap
- has_overlap = true;
- break;
- }
- }
- }
- if (!has_overlap) {
- return slot_num;
- }
- }
- return -1;
- };
-
- // Do slotting.
- for (var i = 0, len = undone.length; i < len; i++) {
- var feature = features[undone[i]],
- feature_uid = feature[0],
- feature_start = feature[1],
- feature_end = feature[2],
- feature_name = feature[3],
- // Where to start, end drawing on screen.
- f_start = Math.floor( feature_start * w_scale ),
- f_end = Math.ceil( feature_end * w_scale ),
- text_len = this.measureText(feature_name).width,
- text_align;
-
- // Update start, end drawing locations to include feature name.
- // Try to put the name on the left, if not, put on right.
- if (feature_name !== undefined && this.include_label ) {
- // Add gap for label spacing and extra pack space padding
- // TODO: Fix constants
- text_len += (LABEL_SPACING + PACK_SPACING);
- if (f_start - text_len >= 0) {
- f_start -= text_len;
- text_align = "left";
- } else {
- f_end += text_len;
- text_align = "right";
- }
- }
-
- // Find slot.
- var slot_num = find_slot(f_start, f_end);
+ // TODO: Should calculate zoom tile index, which will improve performance
+ // by only having to look at a smaller subset
+ // if (this.start_end_dct[0] === undefined) { this.start_end_dct[0] = []; }
+ for (var i = 0, len = features.length; i < len; i++) {
+ var feature = features[i],
+ feature_uid = feature[0];
+ if (inc_slots[feature_uid] !== undefined) {
+ highest_slot = Math.max(highest_slot, inc_slots[feature_uid]);
+ slotted.push(inc_slots[feature_uid]);
+ } else {
+ undone.push(i);
+ }
+ }
+
+ // Slot unslotted features.
+
+ // Find the first slot such that current feature doesn't overlap any other features in that slot.
+ // Returns -1 if no slot was found.
+ var find_slot = function(f_start, f_end) {
+ // TODO: Fix constants
+ for (var slot_num = 0; slot_num <= max_rows; slot_num++) {
+ var has_overlap = false,
+ slot = start_end_dct[slot_num];
+ if (slot !== undefined) {
+ // Iterate through features already in slot to see if current feature will fit.
+ for (var k = 0, k_len = slot.length; k < k_len; k++) {
+ var s_e = slot[k];
+ if (f_end > s_e[0] && f_start < s_e[1]) {
+ // There is overlap
+ has_overlap = true;
+ break;
+ }
+ }
+ }
+ if (!has_overlap) {
+ return slot_num;
+ }
+ }
+ return -1;
+ };
+
+ // Do slotting.
+ for (var i = 0, len = undone.length; i < len; i++) {
+ var feature = features[undone[i]],
+ feature_uid = feature[0],
+ feature_start = feature[1],
+ feature_end = feature[2],
+ feature_name = feature[3],
+ // Where to start, end drawing on screen.
+ f_start = Math.floor( feature_start * w_scale ),
+ f_end = Math.ceil( feature_end * w_scale ),
+ text_len = this.measureText(feature_name).width,
+ text_align;
+
+ // Update start, end drawing locations to include feature name.
+ // Try to put the name on the left, if not, put on right.
+ if (feature_name !== undefined && this.include_label ) {
+ // Add gap for label spacing and extra pack space padding
+ // TODO: Fix constants
+ text_len += (LABEL_SPACING + PACK_SPACING);
+ if (f_start - text_len >= 0) {
+ f_start -= text_len;
+ text_align = "left";
+ } else {
+ f_end += text_len;
+ text_align = "right";
+ }
+ }
+
+ // Find slot.
+ var slot_num = find_slot(f_start, f_end);
- /*
- if (slot_num < 0) {
-
- TODO: this is not yet working --
- console.log(feature_uid, "looking for slot with text on the right");
- // Slot not found. If text was on left, try on right and see
- // if slot can be found.
- // TODO: are there any checks we need to do to ensure that text
- // will fit on tile?
- if (text_align === "left") {
- f_start -= text_len;
- f_end -= text_len;
- text_align = "right";
- slot_num = find_slot(f_start, f_end);
- }
- if (slot_num >= 0) {
- console.log(feature_uid, "found slot with text on the right");
- }
+ /*
+ if (slot_num < 0) {
+
+ TODO: this is not yet working --
+ console.log(feature_uid, "looking for slot with text on the right");
+ // Slot not found. If text was on left, try on right and see
+ // if slot can be found.
+ // TODO: are there any checks we need to do to ensure that text
+ // will fit on tile?
+ if (text_align === "left") {
+ f_start -= text_len;
+ f_end -= text_len;
+ text_align = "right";
+ slot_num = find_slot(f_start, f_end);
+ }
+ if (slot_num >= 0) {
+ console.log(feature_uid, "found slot with text on the right");
+ }
- }
- */
- // Do slotting.
- if (slot_num >= 0) {
- // Add current feature to slot.
- if (start_end_dct[slot_num] === undefined) {
- start_end_dct[slot_num] = [];
- }
- start_end_dct[slot_num].push([f_start, f_end]);
- inc_slots[feature_uid] = slot_num;
- highest_slot = Math.max(highest_slot, slot_num);
- }
- else {
- // TODO: remove this warning when skipped features are handled.
- // Show warning for skipped feature.
- //console.log("WARNING: not displaying feature", feature_uid, f_start, f_end);
- }
- }
-
- // Debugging: view slots data.
- /*
- for (var i = 0; i < MAX_FEATURE_DEPTH; i++) {
- var slot = start_end_dct[i];
- if (slot !== undefined) {
- console.log(i, "*************");
- for (var k = 0, k_len = slot.length; k < k_len; k++) {
- console.log("\t", slot[k][0], slot[k][1]);
- }
- }
- }
- */
- return highest_slot + 1;
+ }
+ */
+ // Do slotting.
+ if (slot_num >= 0) {
+ // Add current feature to slot.
+ if (start_end_dct[slot_num] === undefined) {
+ start_end_dct[slot_num] = [];
+ }
+ start_end_dct[slot_num].push([f_start, f_end]);
+ inc_slots[feature_uid] = slot_num;
+ highest_slot = Math.max(highest_slot, slot_num);
+ }
+ else {
+ // TODO: remove this warning when skipped features are handled.
+ // Show warning for skipped feature.
+ //console.log("WARNING: not displaying feature", feature_uid, f_start, f_end);
+ }
+ }
+
+ // Debugging: view slots data.
+ /*
+ for (var i = 0; i < MAX_FEATURE_DEPTH; i++) {
+ var slot = start_end_dct[i];
+ if (slot !== undefined) {
+ console.log(i, "*************");
+ for (var k = 0, k_len = slot.length; k < k_len; k++) {
+ console.log("\t", slot[k][0], slot[k][1]);
+ }
+ }
+ }
+ */
+ return highest_slot + 1;
}
});
@@ -2807,7 +2807,7 @@
// Slot valid only if features are slotted and this feature is slotted;
// feature may not be due to lack of space.
slot = (slots && slots[feature_uid] !== undefined ? slots[feature_uid] : null);
-
+
// Draw feature if there's overlap and mode is dense or feature is slotted (as it must be for all non-dense modes).
if ( ( feature_start < view_end && feature_end > view_start ) && (this.mode == "Dense" || slot !== null)) {
this.draw_element(ctx, this.mode, feature, slot, view_start, view_end, w_scale, y_scale,
@@ -2876,17 +2876,17 @@
label_color = this.prefs.label_color;
// Dense mode displays the same for all data.
- /*
+ /*
if (mode === "Dense") {
ctx.fillStyle = block_color;
ctx.fillRect(f_start, y_center, f_end - f_start, DENSE_FEATURE_HEIGHT);
}
- */
-
- if ( mode == "Dense" ) {
- slot = 1;
- }
-
+ */
+
+ if ( mode == "Dense" ) {
+ slot = 1;
+ }
+
if (mode === "no_detail") {
// No details for feature, so only one way to display.
ctx.fillStyle = block_color;
@@ -2983,22 +2983,22 @@
block_thick_end = Math.min(block_end, thick_end);
ctx.fillRect(block_thick_start, y_center + 1,
block_thick_end - block_thick_start, thick_height);
- if ( feature_blocks.length == 1 && mode == "Pack") {
- // Exactly one block means we have no introns, but do have a distinct "thick" region,
- // draw arrows over it if in pack mode
- if (feature_strand === "+") {
- ctx.fillStyle = ctx.canvas.manager.get_pattern( 'right_strand_inv' );
- } else if (feature_strand === "-") {
- ctx.fillStyle = ctx.canvas.manager.get_pattern( 'left_strand_inv' );
- }
- // If region is wide enough in pixels, pad a bit
- if ( block_thick_start + 14 < block_thick_end ) {
- block_thick_start += 2;
- block_thick_end -= 2;
- }
- ctx.fillRect( block_thick_start, y_center + 1,
+ if ( feature_blocks.length == 1 && mode == "Pack") {
+ // Exactly one block means we have no introns, but do have a distinct "thick" region,
+ // draw arrows over it if in pack mode
+ if (feature_strand === "+") {
+ ctx.fillStyle = ctx.canvas.manager.get_pattern( 'right_strand_inv' );
+ } else if (feature_strand === "-") {
+ ctx.fillStyle = ctx.canvas.manager.get_pattern( 'left_strand_inv' );
+ }
+ // If region is wide enough in pixels, pad a bit
+ if ( block_thick_start + 14 < block_thick_end ) {
+ block_thick_start += 2;
+ block_thick_end -= 2;
+ }
+ ctx.fillRect( block_thick_start, y_center + 1,
block_thick_end - block_thick_start, thick_height );
- }
+ }
}
}
}
@@ -3006,7 +3006,7 @@
// Draw label for Pack mode.
if (mode === "Pack" && feature_start > tile_low) {
ctx.fillStyle = label_color;
- // FIXME: assumption here that the entire view starts at 0
+ // FIXME: assumption here that the entire view starts at 0
if (tile_low === 0 && f_start - ctx.measureText(feature_name).width < 0) {
ctx.textAlign = "left";
ctx.fillText(feature_name, f_end + LABEL_SPACING, y_center + 8);
@@ -3414,14 +3414,14 @@
var modules = {};
// Provide a require function
var require = function( name ) {
- return modules[name];
+ return modules[name];
};
// Run module will run the module_function provided and store in the
// require dict using key
var run_module = function( key, module_function ) {
- var exports = {};
- module_function( require, exports );
- modules[key] = exports;
+ var exports = {};
+ module_function( require, exports );
+ modules[key] = exports;
};
// Run all modules
run_module( 'slotting', slotting_module );
@@ -3429,6 +3429,6 @@
run_module( 'trackster', trackster_module );
// Export trackster stuff
for ( key in modules.trackster ) {
- target[key] = modules.trackster[key];
+ target[key] = modules.trackster[key];
}
})(window);
\ No newline at end of file
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
02 Apr '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/0b7a4ca37154/
changeset: r5333:0b7a4ca37154
user: james_taylor
date: 2011-04-03 05:12:02
summary: trackster: fix bug with fetching same data many times by putting deferred in data cache immediately, still problematic because many deferred callbacks are queued up and the tile is drawn multiple times, debug statement demonstrates this, needs more refactoring to get it right
affected #: 1 file (292 bytes)
--- a/static/scripts/trackster.js Sat Apr 02 18:30:13 2011 -0400
+++ b/static/scripts/trackster.js Sat Apr 02 23:12:02 2011 -0400
@@ -314,10 +314,11 @@
}
*/
- //
- // Load data from server.
- //
- return this.load_data(chrom, low, high, mode, resolution, extra_params);
+ // Load data from server. The deferred is immediately saved until the
+ // data is ready, it then replaces itself with the actual data
+ entry = this.load_data(chrom, low, high, mode, resolution, extra_params);
+ this.set_data( low, high, mode, entry );
+ return entry
},
set_data: function(low, high, mode, result) {
//console.log("set_data", low, high, mode, result);
@@ -1717,6 +1718,8 @@
var track = this;
// Put a 50ms delay on drawing so that if the user scrolls fast, we don't load extra data
var draw_and_show_tile = function(id, result, resolution, tile_index, parent_element, w_scale, seq_data) {
+ // DEBUG: this is still called too many times when moving slowly,
+ // console.log( "draw_and_show_tile", resolution, tile_index, w_scale );
returned_tile = track.draw_tile(result, resolution, tile_index, parent_element, w_scale, seq_data)
// Wrap element in div for background
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
2 new changesets in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/f8ac9094b145/
changeset: r5331:f8ac9094b145
user: james_taylor
date: 2011-04-02 23:35:27
summary: trackster: drawing labels on left at start of chrom works again, tweaks to feature track padding
affected #: 1 file (0 bytes)
--- a/static/scripts/trackster.js Sat Apr 02 16:43:02 2011 -0400
+++ b/static/scripts/trackster.js Sat Apr 02 17:35:27 2011 -0400
@@ -2776,8 +2776,8 @@
// Calculate new slots incrementally for this new chunk of data and update height if necessary.
required_height = rows_required * y_scale;
}
- // Pad bottom by half a row
- return required_height + Math.round( y_scale / 2 );
+ // Pad bottom by half a row, at least 5 px
+ return required_height + Math.max( Math.round( y_scale / 2 ), 5 );
},
draw: function( ctx, width, height, slots ) {
@@ -3000,9 +3000,8 @@
// Draw label for Pack mode.
if (mode === "Pack" && feature_start > tile_low) {
ctx.fillStyle = label_color;
- // FIXME: do this without tile_index
- var tile_index = 1;
- if (tile_index === 0 && f_start - ctx.measureText(feature_name).width < 0) {
+ // FIXME: assumption here that the entire view starts at 0
+ if (tile_low === 0 && f_start - ctx.measureText(feature_name).width < 0) {
ctx.textAlign = "left";
ctx.fillText(feature_name, f_end + LABEL_SPACING, y_center + 8);
} else {
http://bitbucket.org/galaxy/galaxy-central/changeset/8f250815662e/
changeset: r5332:8f250815662e
user: james_taylor
date: 2011-04-03 00:30:13
summary: trackster: disabling subsetting in data manager, breaks line tracks
affected #: 1 file (80 bytes)
--- a/static/scripts/trackster.js Sat Apr 02 17:35:27 2011 -0400
+++ b/static/scripts/trackster.js Sat Apr 02 18:30:13 2011 -0400
@@ -291,6 +291,8 @@
// the data was "index" or "data." Also could slice the data so that
// only data points in request are returned.
//
+
+ /* Disabling for now, more detailed data is never loaded for line tracks
if (this.subset) {
var key, split_key, entry_low, entry_high, mode, entry;
for (var i = 0; i < this.key_ary.length; i++) {
@@ -310,6 +312,7 @@
}
}
}
+ */
//
// Load data from server.
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: Gracefully handle parsing errors in GFFReader and accurately compute raw size of GFF features.
by Bitbucket 02 Apr '11
by Bitbucket 02 Apr '11
02 Apr '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/ddea56886275/
changeset: r5330:ddea56886275
user: jgoecks
date: 2011-04-02 22:43:02
summary: Gracefully handle parsing errors in GFFReader and accurately compute raw size of GFF features.
affected #: 3 files (346 bytes)
--- a/lib/galaxy/datatypes/converters/gff_to_interval_index_converter.py Sat Apr 02 16:02:30 2011 -0400
+++ b/lib/galaxy/datatypes/converters/gff_to_interval_index_converter.py Sat Apr 02 16:43:02 2011 -0400
@@ -32,7 +32,7 @@
convert_gff_coords_to_bed( feature )
index.add( feature.chrom, feature.start, feature.end, offset )
- offset += feature.raw_size()
+ offset += feature.raw_size
index.write( open(out_fname, "w") )
--- a/lib/galaxy/datatypes/util/gff_util.py Sat Apr 02 16:02:30 2011 -0400
+++ b/lib/galaxy/datatypes/util/gff_util.py Sat Apr 02 16:43:02 2011 -0400
@@ -11,7 +11,7 @@
only attribute is 'group.'
"""
def __init__( self, reader, fields, chrom_col, feature_col, start_col, end_col, \
- strand_col, score_col, default_strand, fix_strand=False, raw_line='' ):
+ strand_col, score_col, default_strand, fix_strand=False ):
# HACK: GFF format allows '.' for strand but GenomicInterval does not. To get around this,
# temporarily set strand and then unset after initing GenomicInterval.
unknown_strand = False
@@ -34,8 +34,7 @@
raise MissingFieldError( "No field for score_col (%d)" % score_col )
self.score = self.fields[ self.score_col ]
- # Attributes specific to GFF.
- self.raw_line = raw_line
+ # GFF attributes.
self.attributes = parse_gff_attributes( fields[8] )
class GFFFeature( GFFInterval ):
@@ -43,11 +42,13 @@
A GFF feature, which can include multiple intervals.
"""
def __init__( self, reader, chrom_col, feature_col, start_col, end_col, \
- strand_col, score_col, default_strand, fix_strand=False, intervals=[] ):
+ strand_col, score_col, default_strand, fix_strand=False, intervals=[], \
+ raw_size=0 ):
GFFInterval.__init__( self, reader, intervals[0].fields, chrom_col, feature_col, \
start_col, end_col, strand_col, score_col, default_strand, \
fix_strand=fix_strand )
self.intervals = intervals
+ self.raw_size = raw_size
# Use intervals to set feature attributes.
for interval in self.intervals:
# Error checking. NOTE: intervals need not share the same strand.
@@ -68,20 +69,6 @@
if not name:
name = self.attributes.get( 'group', None )
return name
-
- def raw_size( self ):
- """
- Returns raw size of feature; raw size is the number of bytes that
- comprise feature.
- """
- # Feature length is all intervals/lines that comprise feature.
- feature_len = 0
- for interval in self.intervals:
- # HACK: +1 for EOL char. Need bx-python to provide raw_line itself
- # b/c TableReader strips EOL characters, thus changing the line
- # length.
- feature_len += len( interval.raw_line ) + 1
- return feature_len
class GFFIntervalToBEDReaderWrapper( NiceReaderWrapper ):
"""
@@ -124,7 +111,7 @@
def parse_row( self, line ):
interval = GFFInterval( self, line.split( "\t" ), self.chrom_col, self.feature_col, \
self.start_col, self.end_col, self.strand_col, self.score_col, \
- self.default_strand, fix_strand=self.fix_strand, raw_line=line )
+ self.default_strand, fix_strand=self.fix_strand )
return interval
def next( self ):
@@ -151,7 +138,8 @@
#
# Get next GFFFeature
- #
+ #
+ raw_size = 0
# If there is no seed interval, set one. Also, if there are no more
# intervals to read, this is where iterator dies.
@@ -161,6 +149,8 @@
self.seed_interval = GenomicIntervalReader.next( self )
except ParseError, e:
handle_parse_error( e )
+ finally:
+ raw_size += len( self.current_line )
# If header or comment, clear seed interval and return it.
if isinstance( self.seed_interval, ( Header, Comment ) ):
@@ -187,6 +177,9 @@
break
except ParseError, e:
handle_parse_error( e )
+ continue
+ finally:
+ raw_size += len( self.current_line )
# If interval not associated with feature, break.
group = interval.attributes.get( 'group', None )
@@ -214,7 +207,7 @@
return GFFFeature( self, self.chrom_col, self.feature_col, self.start_col, \
self.end_col, self.strand_col, self.score_col, \
self.default_strand, fix_strand=self.fix_strand, \
- intervals=feature_intervals )
+ intervals=feature_intervals, raw_size=raw_size )
def convert_bed_coords_to_gff( interval ):
--- a/lib/galaxy/visualization/tracks/data_providers.py Sat Apr 02 16:02:30 2011 -0400
+++ b/lib/galaxy/visualization/tracks/data_providers.py Sat Apr 02 16:43:02 2011 -0400
@@ -658,7 +658,7 @@
payload = package_gff_feature( feature )
payload.insert( 0, offset )
results.append( payload )
- offset += feature.raw_size()
+ offset += feature.raw_size
return { 'data': results, 'message': message }
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
3 new changesets in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/0cd9402d5845/
changeset: r5327:0cd9402d5845
user: james_taylor
date: 2011-04-02 20:36:52
summary: trackster: draw intron/exon structure in dense mode, also restore border top for all tracks
affected #: 3 files (188 bytes)
--- a/static/june_2007_style/blue/trackster.css Sat Apr 02 13:34:08 2011 -0400
+++ b/static/june_2007_style/blue/trackster.css Sat Apr 02 14:36:52 2011 -0400
@@ -22,7 +22,7 @@
.track{background:white;}
.track-header{text-align:left;padding:4px 0px;color:#666;}
.track-header .menubutton{margin-left:0px;}
-.track-content{overflow:hidden;text-align:center;border-bottom:1px solid #bbb;background:#eee url('/static/images/tracks/diag_bg.gif');min-height:16px;}
+.track-content{overflow:hidden;text-align:center;border-top:1px solid #eee;border-bottom:1px solid #eee;background:#eee url('/static/images/tracks/diag_bg.gif');min-height:16px;}
.label-track .track-content{background:white;}
.track-tile{background:white;}
.track-tile canvas{position:relative;z-index:100;border:solid white;border-width:2px 0px 0px 0px;}
--- a/static/june_2007_style/trackster.css.tmpl Sat Apr 02 13:34:08 2011 -0400
+++ b/static/june_2007_style/trackster.css.tmpl Sat Apr 02 14:36:52 2011 -0400
@@ -146,8 +146,8 @@
.track-content {
overflow: hidden;
text-align: center;
-/* border-top: 1px solid #eee; */
- border-bottom: 1px solid #bbb;
+ border-top: 1px solid #eee;
+ border-bottom: 1px solid #eee;
background: #eee url('/static/images/tracks/diag_bg.gif');
min-height: 16px;
}
--- a/static/scripts/trackster.js Sat Apr 02 13:34:08 2011 -0400
+++ b/static/scripts/trackster.js Sat Apr 02 14:36:52 2011 -0400
@@ -2841,7 +2841,7 @@
// Contstants specific to feature tracks moved here (HACKING, these should
// basically all be configuration options)
-var DENSE_TRACK_HEIGHT = 3,
+var DENSE_TRACK_HEIGHT = 10,
NO_DETAIL_TRACK_HEIGHT = 3,
SQUISH_TRACK_HEIGHT = 5,
PACK_TRACK_HEIGHT = 10,
@@ -2898,11 +2898,18 @@
label_color = this.prefs.label_color;
// Dense mode displays the same for all data.
+ /*
if (mode === "Dense") {
ctx.fillStyle = block_color;
ctx.fillRect(f_start, y_center, f_end - f_start, DENSE_FEATURE_HEIGHT);
}
- else if (mode === "no_detail") {
+ */
+
+ if ( mode == "Dense" ) {
+ slot = 1;
+ }
+
+ if (mode === "no_detail") {
// No details for feature, so only one way to display.
ctx.fillStyle = block_color;
// TODO: what should width be here?
@@ -2922,7 +2929,7 @@
// Set vars that depend on mode.
var thin_height, thick_height;
- if (mode === "Squish") {
+ if (mode === "Squish" || mode === "Dense" ) {
thin_height = 1;
thick_height = SQUISH_FEATURE_HEIGHT;
} else { // mode === "Pack"
@@ -2954,7 +2961,7 @@
// Draw whole feature as connector/intron.
var cur_y_center, cur_height;
- if (mode === "Squish") {
+ if (mode === "Squish" || mode === "Dense") {
ctx.fillStyle = CONNECTOR_COLOR;
cur_y_center = y_center + Math.floor(SQUISH_FEATURE_HEIGHT/2) + 1;
cur_height = 1;
@@ -2998,8 +3005,9 @@
block_thick_end = Math.min(block_end, thick_end);
ctx.fillRect(block_thick_start, y_center + 1,
block_thick_end - block_thick_start, thick_height);
- if ( feature_blocks.length == 1 ) {
- // Exactly one block means we have no introns, but do have a distinct "thick" region
+ if ( feature_blocks.length == 1 && mode == "Pack") {
+ // Exactly one block means we have no introns, but do have a distinct "thick" region,
+ // draw arrows over it if in pack mode
if (feature_strand === "+") {
ctx.fillStyle = ctx.canvas.manager.get_pattern( 'right_strand_inv' );
} else if (feature_strand === "-") {
http://bitbucket.org/galaxy/galaxy-central/changeset/fba5ff42c4fe/
changeset: r5328:fba5ff42c4fe
user: james_taylor
date: 2011-04-02 20:46:42
summary: Use extend everywhere instead of $.extend
affected #: 1 file (96 bytes)
--- a/static/scripts/trackster.js Sat Apr 02 14:36:52 2011 -0400
+++ b/static/scripts/trackster.js Sat Apr 02 14:46:42 2011 -0400
@@ -2,6 +2,17 @@
2010-2011: James Taylor, Kanwei Li, Jeremy Goecks
*/
+/** Simple extend function for inheritence */
+var extend = function() {
+ var target = arguments[0];
+ for ( var i = 1; i < arguments.length; i++ ) {
+ var other = arguments[i];
+ for ( key in other ) {
+ target[key] = other[key];
+ }
+ }
+};
+
// Encapsulate -- anything to be availabe outside this block is added to exports
(function(exports){
@@ -30,30 +41,30 @@
this.load_pattern( 'left_strand_inv', "/visualization/strand_left_inv.png" );
}
-CanvasManager.prototype.load_pattern = function( key, path ) {
- var patterns = this.patterns,
- dummy_context = this.dummy_context,
- image = new Image();
- // FIXME: where does image_path come from? not in browser.mako...
- image.src = image_path + path;
- image.onload = function() {
- patterns[key] = dummy_context.createPattern( image, "repeat" );
+extend( CanvasManager.prototype, {
+ load_pattern: function( key, path ) {
+ var patterns = this.patterns,
+ dummy_context = this.dummy_context,
+ image = new Image();
+ // FIXME: where does image_path come from? not in browser.mako...
+ image.src = image_path + path;
+ image.onload = function() {
+ patterns[key] = dummy_context.createPattern( image, "repeat" );
+ }
+ },
+ get_pattern: function( key ) {
+ return this.patterns[key];
+ },
+ new_canvas: function() {
+ var canvas = this.document.createElement("canvas");
+ // If using excanvas in IE, we need to explicately attach the canvas
+ // methods to the DOM element
+ if (window.G_vmlCanvasManager) { G_vmlCanvasManager.initElement(canvas); }
+ // Keep a reference back to the manager
+ canvas.manager = this;
+ return canvas;
}
-}
-
-CanvasManager.prototype.get_pattern = function( key ) {
- return this.patterns[key];
-}
-
-CanvasManager.prototype.new_canvas = function() {
- var canvas = this.document.createElement("canvas");
- // If using excanvas in IE, we need to explicately attach the canvas
- // methods to the DOM element
- if (window.G_vmlCanvasManager) { G_vmlCanvasManager.initElement(canvas); }
- // Keep a reference back to the manager
- canvas.manager = this;
- return canvas;
-}
+});
/**
* Draw a dashed line on a canvas using filled rectangles. This function is based on:
@@ -181,7 +192,7 @@
this.num_elements = num_elements;
this.clear();
};
-$.extend(Cache.prototype, {
+extend(Cache.prototype, {
get: function(key) {
var index = this.key_ary.indexOf(key);
if (index !== -1) {
@@ -225,7 +236,7 @@
this.track = track;
this.subset = (subset !== undefined ? subset : true);
};
-$.extend(DataManager.prototype, Cache.prototype, {
+extend(DataManager.prototype, Cache.prototype, {
/**
* Load data from server; returns AJAX object so that use of Deferred is possible.
*/
@@ -342,7 +353,7 @@
this.canvas_manager = new CanvasManager( container.get(0).ownerDocument );
this.reset();
};
-$.extend( View.prototype, {
+extend( View.prototype, {
init: function( callback ) {
// Create DOM elements
var parent_element = this.container,
@@ -807,7 +818,7 @@
}
}
};
-$.extend(Tool.prototype, {
+extend(Tool.prototype, {
// Returns a dictionary of parameter values; key is parameter name, value
// is parameter value.
get_param_values_dict: function() {
@@ -871,7 +882,7 @@
this.slider = null;
this.slider_label = null;
};
-$.extend(NumberFilter.prototype, {
+extend(NumberFilter.prototype, {
/**
* Returns true if filter can be applied to element.
*/
@@ -963,7 +974,7 @@
}
this.onchange = options.onchange
}
-$.extend( TrackConfig.prototype, {
+extend( TrackConfig.prototype, {
restore_values: function( values ) {
var track_config = this;
$.each( this.params, function( index, param ) {
@@ -1094,7 +1105,7 @@
this.content_div = $("<div class='track-content'>").appendTo(this.container_div);
this.parent_element.append(this.container_div);
};
-$.extend(Track.prototype, {
+extend(Track.prototype, {
/**
* Initialize and draw the track.
*/
@@ -1481,7 +1492,7 @@
}
*/
};
-$.extend(TiledTrack.prototype, Track.prototype, {
+extend(TiledTrack.prototype, Track.prototype, {
/**
* Make popup menu for track name.
*/
@@ -1890,7 +1901,7 @@
Track.call( this, null, view, parent_element );
this.container_div.addClass( "label-track" );
};
-$.extend( LabelTrack.prototype, Track.prototype, {
+extend( LabelTrack.prototype, Track.prototype, {
draw: function() {
var view = this.view,
range = view.high - view.low,
@@ -1930,7 +1941,7 @@
this.data_cache = new DataManager(CACHED_DATA, this, false);
this.tile_cache = new Cache(CACHED_TILES_LINE);
};
-$.extend(ReferenceTrack.prototype, TiledTrack.prototype, {
+extend(ReferenceTrack.prototype, TiledTrack.prototype, {
/**
* Draw ReferenceTrack tile.
*/
@@ -2003,7 +2014,7 @@
this.add_resize_handle();
};
-$.extend(LineTrack.prototype, TiledTrack.prototype, {
+extend(LineTrack.prototype, TiledTrack.prototype, {
add_resize_handle: function () {
// Add control for resizing
// Trickery here to deal with the hovering drag handle, can probably be
@@ -2145,7 +2156,7 @@
this.painter = LinkedFeaturePainter;
};
-$.extend(FeatureTrack.prototype, TiledTrack.prototype, {
+extend(FeatureTrack.prototype, TiledTrack.prototype, {
update_auto_mode: function( mode ) {
if ( this.mode == "Auto" ) {
if ( mode == "no_detail" ) {
@@ -2332,7 +2343,7 @@
this.painter = VariantPainter;
};
-$.extend(VcfTrack.prototype, TiledTrack.prototype, FeatureTrack.prototype);
+extend(VcfTrack.prototype, TiledTrack.prototype, FeatureTrack.prototype);
var ReadTrack = function (name, view, hda_ldda, dataset_id, prefs, filters) {
@@ -2360,7 +2371,7 @@
this.painter = ReadPainter;
this.make_name_popup_menu();
};
-$.extend(ReadTrack.prototype, TiledTrack.prototype, FeatureTrack.prototype);
+extend(ReadTrack.prototype, TiledTrack.prototype, FeatureTrack.prototype);
/**
* Feature track that displays data generated from tool.
@@ -2376,7 +2387,7 @@
this.dataset_check_url = dataset_state_url;
};
-$.extend(ToolDataFeatureTrack.prototype, TiledTrack.prototype, FeatureTrack.prototype, {
+extend(ToolDataFeatureTrack.prototype, TiledTrack.prototype, FeatureTrack.prototype, {
/**
* For this track type, the predraw init sets up postdraw init.
*/
@@ -2414,18 +2425,6 @@
// ---- To be extracted ------------------------------------------------------
-// ---- Simple extend function for inheritence ----
-
-var extend = function() {
- var target = arguments[0];
- for ( var i = 1; i < arguments.length; i++ ) {
- var other = arguments[i];
- for ( key in other ) {
- target[key] = other[key];
- }
- }
-}
-
// ---- Feature Packing ----
/**
http://bitbucket.org/galaxy/galaxy-central/changeset/60f02d9f79af/
changeset: r5329:60f02d9f79af
user: james_taylor
date: 2011-04-02 22:02:30
summary: trackster: everything now contained in three distinct modules using CommonJS exports/require style, more fixing coupling and global variables
affected #: 1 file (568 bytes)
--- a/static/scripts/trackster.js Sat Apr 02 14:46:42 2011 -0400
+++ b/static/scripts/trackster.js Sat Apr 02 16:02:30 2011 -0400
@@ -14,8 +14,11 @@
};
// Encapsulate -- anything to be availabe outside this block is added to exports
-(function(exports){
+var trackster_module = function(require, exports){
+var slotting = require('slotting'),
+ painters = require('painters');
+
// ---- Canvas management and extensions ----
/**
@@ -160,7 +163,8 @@
CHAR_HEIGHT_PX = 9, // FIXME: font size may not be static
ERROR_PADDING = 10, // Padding at the top of tracks for error messages
SUMMARY_TREE_TOP_PADDING = CHAR_HEIGHT_PX + 2,
-
+ // Maximum number of rows un a slotted track
+ MAX_FEATURE_DEPTH = 100,
// Minimum width for window for squish to be used.
MIN_SQUISH_VIEW_WIDTH = 12000,
@@ -2100,8 +2104,8 @@
// Paint line onto full canvas
var ctx = canvas.getContext("2d");
- var painter = new LinePainter( result.data, tile_low, tile_low + tile_length,
- this.prefs.min_value, this.prefs.max_value, this.prefs.color, this.mode );
+ var painter = new painters.LinePainter( result.data, tile_low, tile_low + tile_length,
+ this.prefs.min_value, this.prefs.max_value, this.prefs.color, this.mode );
painter.draw( ctx, width, height );
return canvas;
@@ -2154,7 +2158,7 @@
this.data_cache = new DataManager(20, this);
this.left_offset = 200;
- this.painter = LinkedFeaturePainter;
+ this.painter = painters.LinkedFeaturePainter;
};
extend(FeatureTrack.prototype, TiledTrack.prototype, {
update_auto_mode: function( mode ) {
@@ -2182,11 +2186,11 @@
var dummy_context = this.view.canvas_manager.dummy_context,
inc_slots = this.inc_slots[level];
if (!inc_slots || (inc_slots.mode !== mode)) {
- inc_slots = new FeatureSlotter( level, mode === "Pack", function ( x ) { return dummy_context.measureText( x ) } );
- inc_slots.mode = mode;
+ inc_slots = new (slotting.FeatureSlotter)( level, mode === "Pack", MAX_FEATURE_DEPTH, function ( x ) { return dummy_context.measureText( x ) } );
+ inc_slots.mode = mode;
this.inc_slots[level] = inc_slots;
}
-
+
return inc_slots.slot_features( features );
},
/**
@@ -2249,7 +2253,7 @@
// Extra padding at top of summary tree
canvas.height = required_height + SUMMARY_TREE_TOP_PADDING;
// Paint summary tree into canvas
- var painter = new SummaryTreePainter( result.data, result.delta, result.max, tile_low, tile_high, this.prefs.show_counts );
+ var painter = new painters.SummaryTreePainter( result.data, result.delta, result.max, tile_low, tile_high, this.prefs.show_counts );
var ctx = canvas.getContext("2d");
// Deal with left_offset by translating
ctx.translate( left_offset, SUMMARY_TREE_TOP_PADDING );
@@ -2340,7 +2344,7 @@
var VcfTrack = function(name, view, hda_ldda, dataset_id, prefs, filters) {
FeatureTrack.call(this, name, view, hda_ldda, dataset_id, prefs, filters);
this.track_type = "VcfTrack";
- this.painter = VariantPainter;
+ this.painter = painters.VariantPainter;
};
extend(VcfTrack.prototype, TiledTrack.prototype, FeatureTrack.prototype);
@@ -2368,7 +2372,7 @@
this.prefs = this.track_config.values;
this.track_type = "ReadTrack";
- this.painter = ReadPainter;
+ this.painter = painters.ReadPainter;
this.make_name_popup_menu();
};
extend(ReadTrack.prototype, TiledTrack.prototype, FeatureTrack.prototype);
@@ -2419,57 +2423,19 @@
exports.FeatureTrack = FeatureTrack;
exports.ReadTrack = ReadTrack;
-// End encapsulation, this line is browser specific, globals are added to the
-// window object
-})(window);
+// End trackster_module encapsulation
+};
// ---- To be extracted ------------------------------------------------------
// ---- Feature Packing ----
-/**
- * Compute the type of overlap between two regions. They are assumed to be on the same chrom/contig.
- * The overlap is computed relative to the second region; hence, OVERLAP_START indicates that the first
- * region overlaps the start (but not the end) of the second region.
- */
-var NO_OVERLAP = 1001, CONTAINS = 1002, OVERLAP_START = 1003, OVERLAP_END = 1004, CONTAINED_BY = 1005;
-var compute_overlap = function(first_region, second_region) {
- var
- first_start = first_region[0], first_end = first_region[1],
- second_start = second_region[0], second_end = second_region[1],
- overlap;
- if (first_start < second_start) {
- if (first_end < second_start) {
- overlap = NO_OVERLAP;
- }
- else if (first_end <= second_end) {
- overlap = OVERLAP_START;
- }
- else { // first_end > second_end
- overlap = CONTAINS;
- }
- }
- else { // first_start >= second_start
- if (first_start > second_end) {
- overlap = NO_OVERLAP;
- }
- else if (first_end <= second_end) {
- overlap = CONTAINED_BY;
- }
- else {
- overlap = OVERLAP_END;
- }
- }
-
- return overlap;
-}
+// Encapsulation
+var slotting_module = function(require, exports) {
-/**
- * Returns true if there is any overlap between regions.
- */
-var is_overlap = function(first_region, second_region) {
- return (compute_overlap(first_region, second_region) !== NO_OVERLAP);
-}
+// HACK: LABEL_SPACING is currently duplicated between here and painters
+var LABEL_SPACING = 2,
+ PACK_SPACING = 5;
/**
* FeatureSlotter determines slots in which to draw features for vertical
@@ -2478,11 +2444,12 @@
* This implementation is incremental, any feature assigned a slot will be
* retained for slotting future features.
*/
-var FeatureSlotter = function ( w_scale, include_label, measureText ) {
+exports.FeatureSlotter = function ( w_scale, include_label, max_rows, measureText ) {
this.slots = {};
this.start_end_dct = {};
this.w_scale = w_scale;
this.include_label = include_label;
+ this.max_rows = max_rows;
this.measureText = measureText;
}
@@ -2490,139 +2457,147 @@
* Slot a set of features, `this.slots` will be updated with slots by id, and
* the largest slot required for the passed set of features is returned
*/
-FeatureSlotter.prototype.slot_features = function( features ) {
- var w_scale = this.w_scale, inc_slots = this.slots, start_end_dct = this.start_end_dct,
- undone = [], slotted = [], highest_slot = 0;
+extend( exports.FeatureSlotter.prototype, {
+ slot_features: function( features ) {
+ var w_scale = this.w_scale, inc_slots = this.slots, start_end_dct = this.start_end_dct,
+ undone = [], slotted = [], highest_slot = 0, max_rows = this.max_rows;
+
+ // If feature already exists in slots (from previously seen tiles), use the same slot,
+ // otherwise if not seen, add to "undone" list for slot calculation.
- // If feature already exists in slots (from previously seen tiles), use the same slot,
- // otherwise if not seen, add to "undone" list for slot calculation.
+ // TODO: Should calculate zoom tile index, which will improve performance
+ // by only having to look at a smaller subset
+ // if (this.start_end_dct[0] === undefined) { this.start_end_dct[0] = []; }
+ for (var i = 0, len = features.length; i < len; i++) {
+ var feature = features[i],
+ feature_uid = feature[0];
+ if (inc_slots[feature_uid] !== undefined) {
+ highest_slot = Math.max(highest_slot, inc_slots[feature_uid]);
+ slotted.push(inc_slots[feature_uid]);
+ } else {
+ undone.push(i);
+ }
+ }
+
+ // Slot unslotted features.
+
+ // Find the first slot such that current feature doesn't overlap any other features in that slot.
+ // Returns -1 if no slot was found.
+ var find_slot = function(f_start, f_end) {
+ // TODO: Fix constants
+ for (var slot_num = 0; slot_num <= max_rows; slot_num++) {
+ var has_overlap = false,
+ slot = start_end_dct[slot_num];
+ if (slot !== undefined) {
+ // Iterate through features already in slot to see if current feature will fit.
+ for (var k = 0, k_len = slot.length; k < k_len; k++) {
+ var s_e = slot[k];
+ if (f_end > s_e[0] && f_start < s_e[1]) {
+ // There is overlap
+ has_overlap = true;
+ break;
+ }
+ }
+ }
+ if (!has_overlap) {
+ return slot_num;
+ }
+ }
+ return -1;
+ };
+
+ // Do slotting.
+ for (var i = 0, len = undone.length; i < len; i++) {
+ var feature = features[undone[i]],
+ feature_uid = feature[0],
+ feature_start = feature[1],
+ feature_end = feature[2],
+ feature_name = feature[3],
+ // Where to start, end drawing on screen.
+ f_start = Math.floor( feature_start * w_scale ),
+ f_end = Math.ceil( feature_end * w_scale ),
+ text_len = this.measureText(feature_name).width,
+ text_align;
+
+ // Update start, end drawing locations to include feature name.
+ // Try to put the name on the left, if not, put on right.
+ if (feature_name !== undefined && this.include_label ) {
+ // Add gap for label spacing and extra pack space padding
+ // TODO: Fix constants
+ text_len += (LABEL_SPACING + PACK_SPACING);
+ if (f_start - text_len >= 0) {
+ f_start -= text_len;
+ text_align = "left";
+ } else {
+ f_end += text_len;
+ text_align = "right";
+ }
+ }
+
+ // Find slot.
+ var slot_num = find_slot(f_start, f_end);
- // TODO: Should calculate zoom tile index, which will improve performance
- // by only having to look at a smaller subset
- // if (this.start_end_dct[0] === undefined) { this.start_end_dct[0] = []; }
- for (var i = 0, len = features.length; i < len; i++) {
- var feature = features[i],
- feature_uid = feature[0];
- if (inc_slots[feature_uid] !== undefined) {
- highest_slot = Math.max(highest_slot, inc_slots[feature_uid]);
- slotted.push(inc_slots[feature_uid]);
- } else {
- undone.push(i);
- }
+ /*
+ if (slot_num < 0) {
+
+ TODO: this is not yet working --
+ console.log(feature_uid, "looking for slot with text on the right");
+ // Slot not found. If text was on left, try on right and see
+ // if slot can be found.
+ // TODO: are there any checks we need to do to ensure that text
+ // will fit on tile?
+ if (text_align === "left") {
+ f_start -= text_len;
+ f_end -= text_len;
+ text_align = "right";
+ slot_num = find_slot(f_start, f_end);
+ }
+ if (slot_num >= 0) {
+ console.log(feature_uid, "found slot with text on the right");
+ }
+
+ }
+ */
+ // Do slotting.
+ if (slot_num >= 0) {
+ // Add current feature to slot.
+ if (start_end_dct[slot_num] === undefined) {
+ start_end_dct[slot_num] = [];
+ }
+ start_end_dct[slot_num].push([f_start, f_end]);
+ inc_slots[feature_uid] = slot_num;
+ highest_slot = Math.max(highest_slot, slot_num);
+ }
+ else {
+ // TODO: remove this warning when skipped features are handled.
+ // Show warning for skipped feature.
+ //console.log("WARNING: not displaying feature", feature_uid, f_start, f_end);
+ }
+ }
+
+ // Debugging: view slots data.
+ /*
+ for (var i = 0; i < MAX_FEATURE_DEPTH; i++) {
+ var slot = start_end_dct[i];
+ if (slot !== undefined) {
+ console.log(i, "*************");
+ for (var k = 0, k_len = slot.length; k < k_len; k++) {
+ console.log("\t", slot[k][0], slot[k][1]);
+ }
+ }
+ }
+ */
+ return highest_slot + 1;
}
-
- // Slot unslotted features.
-
- // Find the first slot such that current feature doesn't overlap any other features in that slot.
- // Returns -1 if no slot was found.
- var find_slot = function(f_start, f_end) {
- // TODO: Fix constants
- for (var slot_num = 0; slot_num <= MAX_FEATURE_DEPTH; slot_num++) {
- var has_overlap = false,
- slot = start_end_dct[slot_num];
- if (slot !== undefined) {
- // Iterate through features already in slot to see if current feature will fit.
- for (var k = 0, k_len = slot.length; k < k_len; k++) {
- var s_e = slot[k];
- if (f_end > s_e[0] && f_start < s_e[1]) {
- // There is overlap
- has_overlap = true;
- break;
- }
- }
- }
- if (!has_overlap) {
- return slot_num;
- }
- }
- return -1;
- };
-
- // Do slotting.
- for (var i = 0, len = undone.length; i < len; i++) {
- var feature = features[undone[i]],
- feature_uid = feature[0],
- feature_start = feature[1],
- feature_end = feature[2],
- feature_name = feature[3],
- // Where to start, end drawing on screen.
- f_start = Math.floor( feature_start * w_scale ),
- f_end = Math.ceil( feature_end * w_scale ),
- text_len = this.measureText(feature_name).width,
- text_align;
-
- // Update start, end drawing locations to include feature name.
- // Try to put the name on the left, if not, put on right.
- if (feature_name !== undefined && this.include_label ) {
- // Add gap for label spacing and extra pack space padding
- // TODO: Fix constants
- text_len += (LABEL_SPACING + PACK_SPACING);
- if (f_start - text_len >= 0) {
- f_start -= text_len;
- text_align = "left";
- } else {
- f_end += text_len;
- text_align = "right";
- }
- }
-
- // Find slot.
- var slot_num = find_slot(f_start, f_end);
- /*
- if (slot_num < 0) {
-
- TODO: this is not yet working --
- console.log(feature_uid, "looking for slot with text on the right");
- // Slot not found. If text was on left, try on right and see
- // if slot can be found.
- // TODO: are there any checks we need to do to ensure that text
- // will fit on tile?
- if (text_align === "left") {
- f_start -= text_len;
- f_end -= text_len;
- text_align = "right";
- slot_num = find_slot(f_start, f_end);
- }
- if (slot_num >= 0) {
- console.log(feature_uid, "found slot with text on the right");
- }
+});
- }
- */
- // Do slotting.
- if (slot_num >= 0) {
- // Add current feature to slot.
- if (start_end_dct[slot_num] === undefined) {
- start_end_dct[slot_num] = [];
- }
- start_end_dct[slot_num].push([f_start, f_end]);
- inc_slots[feature_uid] = slot_num;
- highest_slot = Math.max(highest_slot, slot_num);
- }
- else {
- // TODO: remove this warning when skipped features are handled.
- // Show warning for skipped feature.
- //console.log("WARNING: not displaying feature", feature_uid, f_start, f_end);
- }
- }
-
- // Debugging: view slots data.
- /*
- for (var i = 0; i < MAX_FEATURE_DEPTH; i++) {
- var slot = start_end_dct[i];
- if (slot !== undefined) {
- console.log(i, "*************");
- for (var k = 0, k_len = slot.length; k < k_len; k++) {
- console.log("\t", slot[k][0], slot[k][1]);
- }
- }
- }
- */
- return highest_slot + 1;
-}
+// End slotting_module encapsulation
+};
// ---- Painters ----
+var painters_module = function(require, exports){
+
/**
* SummaryTreePainter, a histogram showing number of intervals in a region
*/
@@ -2826,9 +2801,9 @@
// Slot valid only if features are slotted and this feature is slotted;
// feature may not be due to lack of space.
slot = (slots && slots[feature_uid] !== undefined ? slots[feature_uid] : null);
-
+
// Draw feature if there's overlap and mode is dense or feature is slotted (as it must be for all non-dense modes).
- if (is_overlap([feature_start, feature_end], [view_start, view_end]) && (this.mode == "Dense" || slot !== null)) {
+ if ( ( feature_start < view_end && feature_end > view_start ) && (this.mode == "Dense" || slot !== null)) {
this.draw_element(ctx, this.mode, feature, slot, view_start, view_end, w_scale, y_scale,
width );
}
@@ -2849,8 +2824,6 @@
SQUISH_FEATURE_HEIGHT = 3,
PACK_FEATURE_HEIGHT = 9,
LABEL_SPACING = 2,
- PACK_SPACING = 5,
- MAX_FEATURE_DEPTH = 100,
CONNECTOR_COLOR = "#ccc";
var LinkedFeaturePainter = function( data, view_start, view_end, prefs, mode ) {
@@ -3099,6 +3072,43 @@
}
});
+/**
+ * Compute the type of overlap between two regions. They are assumed to be on the same chrom/contig.
+ * The overlap is computed relative to the second region; hence, OVERLAP_START indicates that the first
+ * region overlaps the start (but not the end) of the second region.
+ */
+var NO_OVERLAP = 1001, CONTAINS = 1002, OVERLAP_START = 1003, OVERLAP_END = 1004, CONTAINED_BY = 1005;
+var compute_overlap = function(first_region, second_region) {
+ var
+ first_start = first_region[0], first_end = first_region[1],
+ second_start = second_region[0], second_end = second_region[1],
+ overlap;
+ if (first_start < second_start) {
+ if (first_end < second_start) {
+ overlap = NO_OVERLAP;
+ }
+ else if (first_end <= second_end) {
+ overlap = OVERLAP_START;
+ }
+ else { // first_end > second_end
+ overlap = CONTAINS;
+ }
+ }
+ else { // first_start >= second_start
+ if (first_start > second_end) {
+ overlap = NO_OVERLAP;
+ }
+ else if (first_end <= second_end) {
+ overlap = CONTAINED_BY;
+ }
+ else {
+ overlap = OVERLAP_END;
+ }
+ }
+
+ return overlap;
+}
+
var ReadPainter = function( data, view_start, view_end, prefs, mode, ref_seq ) {
FeaturePainter.call( this, data, view_start, view_end, prefs, mode );
this.ref_seq = ref_seq;
@@ -3381,3 +3391,39 @@
}
}
});
+
+exports.SummaryTreePainter = SummaryTreePainter;
+exports.LinePainter = LinePainter;
+exports.LinkedFeaturePainter = LinkedFeaturePainter;
+exports.ReadPainter = ReadPainter;
+exports.VariantPainter = VariantPainter;
+
+// End painters_module encapsulation
+};
+
+// Finally, compose and export trackster module exports into globals
+// These will be replaced with require statements in CommonJS
+(function(target){
+ // Faking up a CommonJS like loader here, each module gets a require and
+ // and exports. We avoid resolution problems by just ordering carefully.
+ var modules = {};
+ // Provide a require function
+ var require = function( name ) {
+ return modules[name];
+ };
+ // Run module will run the module_function provided and store in the
+ // require dict using key
+ var run_module = function( key, module_function ) {
+ var exports = {};
+ module_function( require, exports );
+ modules[key] = exports;
+ };
+ // Run all modules
+ run_module( 'slotting', slotting_module );
+ run_module( 'painters', painters_module );
+ run_module( 'trackster', trackster_module );
+ // Export trackster stuff
+ for ( key in modules.trackster ) {
+ target[key] = modules.trackster[key];
+ }
+})(window);
\ No newline at end of file
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
4 new changesets in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/5acc2f533b87/
changeset: r5323:5acc2f533b87
user: james_taylor
date: 2011-04-02 18:20:22
summary: trackster: encapsulate tracks in a closure to ensure global variables are not leaking, eliminated many global variables and moved others to the painters (where they should become configurable). Should have no globals that are shared between Tracks and Painters. Also, some drawing tweaks: thicker dense display, cleaner axis line for line tracks, when in auto mode, the actual mode is displayed in parens
affected #: 1 file (841 bytes)
--- a/static/scripts/trackster.js Sat Apr 02 10:05:24 2011 -0400
+++ b/static/scripts/trackster.js Sat Apr 02 12:20:22 2011 -0400
@@ -2,6 +2,59 @@
2010-2011: James Taylor, Kanwei Li, Jeremy Goecks
*/
+// Encapsulate -- anything to be availabe outside this block is added to exports
+(function(exports){
+
+// ---- Canvas management and extensions ----
+
+/**
+ * Canvas manager is used to create canvases, for browsers, this deals with
+ * backward comparibility using excanvas, as well as providing a pattern cache
+ */
+var CanvasManager = function( document, default_font ) {
+ this.document = document;
+ this.default_font = default_font !== undefined ? default_font : "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 = {};
+
+ // FIXME: move somewhere to make this more general
+ 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" );
+}
+
+CanvasManager.prototype.load_pattern = function( key, path ) {
+ var patterns = this.patterns,
+ dummy_context = this.dummy_context,
+ image = new Image();
+ // FIXME: where does image_path come from? not in browser.mako...
+ image.src = image_path + path;
+ image.onload = function() {
+ patterns[key] = dummy_context.createPattern( image, "repeat" );
+ }
+}
+
+CanvasManager.prototype.get_pattern = function( key ) {
+ return this.patterns[key];
+}
+
+CanvasManager.prototype.new_canvas = function() {
+ var canvas = this.document.createElement("canvas");
+ // If using excanvas in IE, we need to explicately attach the canvas
+ // methods to the DOM element
+ if (window.G_vmlCanvasManager) { G_vmlCanvasManager.initElement(canvas); }
+ // Keep a reference back to the manager
+ canvas.manager = this;
+ return canvas;
+}
+
/**
* Draw a dashed line on a canvas using filled rectangles. This function is based on:
* http://vetruvet.blogspot.com/2010/10/drawing-dashed-lines-on-html5-canvas.h…
@@ -48,10 +101,12 @@
ctx.closePath();
};
+// ---- Web UI specific utilities ----
+
/**
* Make `element` sortable in parent by dragging `handle` (a selector)
*/
-function sortable( element, handle ) {
+var sortable = function( element, handle ) {
element.bind( "drag", { handle: handle, relative: true }, function ( e, d ) {
var parent = $(this).parent();
var children = parent.children();
@@ -77,53 +132,9 @@
}
/**
- * Compute the type of overlap between two regions. They are assumed to be on the same chrom/contig.
- * The overlap is computed relative to the second region; hence, OVERLAP_START indicates that the first
- * region overlaps the start (but not the end) of the second region.
- */
-var NO_OVERLAP = 1001, CONTAINS = 1002, OVERLAP_START = 1003, OVERLAP_END = 1004, CONTAINED_BY = 1005;
-function compute_overlap(first_region, second_region) {
- var
- first_start = first_region[0], first_end = first_region[1],
- second_start = second_region[0], second_end = second_region[1],
- overlap;
- if (first_start < second_start) {
- if (first_end < second_start) {
- overlap = NO_OVERLAP;
- }
- else if (first_end <= second_end) {
- overlap = OVERLAP_START;
- }
- else { // first_end > second_end
- overlap = CONTAINS;
- }
- }
- else { // first_start >= second_start
- if (first_start > second_end) {
- overlap = NO_OVERLAP;
- }
- else if (first_end <= second_end) {
- overlap = CONTAINED_BY;
- }
- else {
- overlap = OVERLAP_END;
- }
- }
-
- return overlap;
-}
-
-/**
- * Returns true if there is any overlap between regions.
- */
-function is_overlap(first_region, second_region) {
- return (compute_overlap(first_region, second_region) !== NO_OVERLAP);
-}
-
-/**
* Calculates step for slider with a given min, max.
*/
-function get_slider_step(min, max) {
+var get_slider_step = function(min, max) {
var range = max - min;
return (range <= 1 ? 0.01 : (range <= 1000 ? 1 : 5));
}
@@ -134,30 +145,20 @@
var
// Drawing constants; track height is (constant) height of track, and feature height is the
// height of individual features within tracks. Feature height, then, should always be less
- // than track height.
- DENSE_TRACK_HEIGHT = 10,
- NO_DETAIL_TRACK_HEIGHT = 3,
- SQUISH_TRACK_HEIGHT = 5,
- PACK_TRACK_HEIGHT = 10,
- NO_DETAIL_FEATURE_HEIGHT = 1,
- DENSE_FEATURE_HEIGHT = 1,
- SQUISH_FEATURE_HEIGHT = 3,
- PACK_FEATURE_HEIGHT = 9,
+ // than track height.
+ CHAR_HEIGHT_PX = 9, // FIXME: font size may not be static
ERROR_PADDING = 10, // Padding at the top of tracks for error messages
- LABEL_SPACING = 2,
- PACK_SPACING = 5,
+ SUMMARY_TREE_TOP_PADDING = CHAR_HEIGHT_PX + 2,
+
// Minimum width for window for squish to be used.
MIN_SQUISH_VIEW_WIDTH = 12000,
// Other constants.
- DEFAULT_FONT = "9px Monaco, Lucida Console, monospace",
DENSITY = 200,
FEATURE_LEVELS = 10,
- MAX_FEATURE_DEPTH = 100,
DEFAULT_DATA_QUERY_WAIT = 5000,
// Maximum number of chromosomes that are selectable at any one time.
MAX_CHROMS_SELECTABLE = 100,
- CONNECTOR_COLOR = "#ccc",
DATA_ERROR = "There was an error in indexing this dataset. ",
DATA_NOCONVERTER = "A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",
DATA_NONE = "No data for this chrom/contig.",
@@ -167,41 +168,7 @@
DATA_OK = "Ready for display",
CACHED_TILES_FEATURE = 10,
CACHED_TILES_LINE = 5,
- CACHED_DATA = 5,
- DUMMY_CANVAS = document.createElement("canvas"),
- RIGHT_STRAND, LEFT_STRAND;
-
-// Get information for rendering canvas elements.
-if (window.G_vmlCanvasManager) {
- G_vmlCanvasManager.initElement(DUMMY_CANVAS);
-}
-var
- CONTEXT = DUMMY_CANVAS.getContext("2d");
-CONTEXT.font = DEFAULT_FONT; // To ensure consistent measureText width
-var
- CHAR_WIDTH_PX = CONTEXT.measureText("A").width,
- CHAR_HEIGHT_PX = 9; // Taken from DEFAULT_FONT.
-
-var right_img = new Image();
-right_img.src = image_path + "/visualization/strand_right.png";
-right_img.onload = function() {
- RIGHT_STRAND = CONTEXT.createPattern(right_img, "repeat");
-};
-var left_img = new Image();
-left_img.src = image_path + "/visualization/strand_left.png";
-left_img.onload = function() {
- LEFT_STRAND = CONTEXT.createPattern(left_img, "repeat");
-};
-var right_img_inv = new Image();
-right_img_inv.src = image_path + "/visualization/strand_right_inv.png";
-right_img_inv.onload = function() {
- RIGHT_STRAND_INV = CONTEXT.createPattern(right_img_inv, "repeat");
-};
-var left_img_inv = new Image();
-left_img_inv.src = image_path + "/visualization/strand_left_inv.png";
-left_img_inv.onload = function() {
- LEFT_STRAND_INV = CONTEXT.createPattern(left_img_inv, "repeat");
-};
+ CACHED_DATA = 5;
function round_1000(num) {
return Math.round(num * 1000) / 1000;
@@ -1954,7 +1921,6 @@
view.reference_track = this;
this.left_offset = 200;
this.height_px = 12;
- this.font = DEFAULT_FONT;
this.container_div.addClass( "reference-track" );
this.content_div.css("background", "none");
this.content_div.css("min-height", "0px");
@@ -1981,7 +1947,7 @@
var ctx = canvas.getContext("2d");
canvas.width = Math.ceil( tile_length * w_scale + track.left_offset);
canvas.height = track.height_px;
- ctx.font = DEFAULT_FONT;
+ ctx.font = ctx.canvas.manager.default_font;
ctx.textAlign = "center";
for (var c = 0, str_len = seq.length; c < str_len; c++) {
var c_start = Math.round(c * w_scale);
@@ -2171,7 +2137,6 @@
this.show_labels_scale = 0.001;
this.showing_details = false;
this.summary_draw_height = 30;
- this.default_font = DEFAULT_FONT;
this.inc_slots = {};
this.start_end_dct = {};
this.tile_cache = new Cache(CACHED_TILES_FEATURE);
@@ -2181,6 +2146,16 @@
this.painter = LinkedFeaturePainter;
};
$.extend(FeatureTrack.prototype, TiledTrack.prototype, {
+ update_auto_mode: function( mode ) {
+ if ( this.mode == "Auto" ) {
+ if ( mode == "no_detail" ) {
+ mode = "reduced to feature spans";
+ } else if ( mode == "summary_tree" ) {
+ mode = "reduced to foverage histogram";
+ }
+ this.mode_div.text( "Auto (" + mode + ")" );
+ }
+ },
/**
* Place features in slots for drawing (i.e. pack features).
* this.inc_slots[level] is created in this method. this.inc_slots[level]
@@ -2193,9 +2168,10 @@
// Get/create incremental slots for level. If display mode changed,
// need to create new slots.
- var inc_slots = this.inc_slots[level];
+ var dummy_context = this.view.canvas_manager.dummy_context,
+ inc_slots = this.inc_slots[level];
if (!inc_slots || (inc_slots.mode !== mode)) {
- inc_slots = new FeatureSlotter( level, mode === "Pack", function ( x ) { return CONTEXT.measureText( x ) } );
+ inc_slots = new FeatureSlotter( level, mode === "Pack", function ( x ) { return dummy_context.measureText( x ) } );
inc_slots.mode = mode;
this.inc_slots[level] = inc_slots;
}
@@ -2203,28 +2179,6 @@
return inc_slots.slot_features( features );
},
/**
- * Returns y_scale based on mode.
- */
- get_y_scale: function(mode) {
- var y_scale;
- if (mode === "summary_tree") {
- // No scale needed.
- }
- if (mode === "Dense") {
- y_scale = DENSE_TRACK_HEIGHT;
- }
- else if (mode === "no_detail") {
- y_scale = NO_DETAIL_TRACK_HEIGHT;
- }
- else if (mode === "Squish") {
- y_scale = SQUISH_TRACK_HEIGHT;
- }
- else { // mode === "Pack"
- y_scale = PACK_TRACK_HEIGHT;
- }
- return y_scale;
- },
- /**
* Draw FeatureTrack tile.
*/
draw_tile: function(result, resolution, tile_index, parent_element, w_scale, ref_seq) {
@@ -2262,7 +2216,8 @@
} else {
mode = "Pack";
}
- }
+ }
+ this.update_auto_mode( mode );
}
// Drawing the summary tree (feature coverage histogram)
@@ -2281,12 +2236,12 @@
var canvas = this.view.canvas_manager.new_canvas();
canvas.width = width + left_offset;
// Extra padding at top of summary tree
- canvas.height = required_height + LABEL_SPACING + CHAR_HEIGHT_PX;
+ canvas.height = required_height + SUMMARY_TREE_TOP_PADDING;
// Paint summary tree into canvas
var painter = new SummaryTreePainter( result.data, result.delta, result.max, tile_low, tile_high, this.prefs.show_counts );
var ctx = canvas.getContext("2d");
// Deal with left_offset by translating
- ctx.translate( left_offset, 0 );
+ ctx.translate( left_offset, SUMMARY_TREE_TOP_PADDING );
painter.draw( ctx, width, required_height );
// Canvas element is returned
return canvas;
@@ -2336,7 +2291,7 @@
// console.log(( tile_low - this.view.low ) * w_scale, tile_index, w_scale);
var ctx = canvas.getContext("2d");
ctx.fillStyle = this.prefs.block_color;
- ctx.font = this.default_font;
+ ctx.font = ctx.canvas.manager.default_font;
ctx.textAlign = "right";
this.container_div.find(".yaxislabel").remove();
@@ -2446,6 +2401,17 @@
}
});
+// Exports
+
+exports.View = View;
+exports.LineTrack = LineTrack;
+exports.FeatureTrack = FeatureTrack;
+exports.ReadTrack = ReadTrack;
+
+// End encapsulation, this line is browser specific, globals are added to the
+// window object
+})(window);
+
// ---- To be extracted ------------------------------------------------------
// ---- Simple extend function for inheritence ----
@@ -2460,20 +2426,52 @@
}
}
-// ---- Canvas management ----
+// ---- Feature Packing ----
-var CanvasManager = function( document ) {
- this.document = document;
+/**
+ * Compute the type of overlap between two regions. They are assumed to be on the same chrom/contig.
+ * The overlap is computed relative to the second region; hence, OVERLAP_START indicates that the first
+ * region overlaps the start (but not the end) of the second region.
+ */
+var NO_OVERLAP = 1001, CONTAINS = 1002, OVERLAP_START = 1003, OVERLAP_END = 1004, CONTAINED_BY = 1005;
+var compute_overlap = function(first_region, second_region) {
+ var
+ first_start = first_region[0], first_end = first_region[1],
+ second_start = second_region[0], second_end = second_region[1],
+ overlap;
+ if (first_start < second_start) {
+ if (first_end < second_start) {
+ overlap = NO_OVERLAP;
+ }
+ else if (first_end <= second_end) {
+ overlap = OVERLAP_START;
+ }
+ else { // first_end > second_end
+ overlap = CONTAINS;
+ }
+ }
+ else { // first_start >= second_start
+ if (first_start > second_end) {
+ overlap = NO_OVERLAP;
+ }
+ else if (first_end <= second_end) {
+ overlap = CONTAINED_BY;
+ }
+ else {
+ overlap = OVERLAP_END;
+ }
+ }
+
+ return overlap;
}
-CanvasManager.prototype.new_canvas = function() {
- var canvas = this.document.createElement("canvas");
- if (window.G_vmlCanvasManager) { G_vmlCanvasManager.initElement(canvas); } // EXCANVAS HACK
- return canvas;
+/**
+ * Returns true if there is any overlap between regions.
+ */
+var is_overlap = function(first_region, second_region) {
+ return (compute_overlap(first_region, second_region) !== NO_OVERLAP);
}
-// ---- Feature Packing ----
-
/**
* FeatureSlotter determines slots in which to draw features for vertical
* packing.
@@ -2651,7 +2649,7 @@
// Set base Y so that max label and data do not overlap. Base Y is where rectangle bases
// start. However, height of each rectangle is relative to required_height; hence, the
// max rectangle is required_height.
- base_y = height + LABEL_SPACING + CHAR_HEIGHT_PX;
+ base_y = height;
delta_x_px = Math.ceil(delta * w_scale);
ctx.save();
@@ -2712,12 +2710,16 @@
// Line at 0.0
if ( mode !== "Intensity" ) {
+ /*
ctx.beginPath();
ctx.moveTo( 0, y_zero );
ctx.lineTo( width, y_zero );
// ctx.lineWidth = 0.5;
ctx.fillStyle = "#aaa";
ctx.stroke();
+ */
+ ctx.fillStyle = "#aaa";
+ ctx.fillRect( 0, y_zero, width, 1 );
}
ctx.beginPath();
@@ -2837,6 +2839,21 @@
}
});
+// Contstants specific to feature tracks moved here (HACKING, these should
+// basically all be configuration options)
+var DENSE_TRACK_HEIGHT = 3,
+ NO_DETAIL_TRACK_HEIGHT = 3,
+ SQUISH_TRACK_HEIGHT = 5,
+ PACK_TRACK_HEIGHT = 10,
+ NO_DETAIL_FEATURE_HEIGHT = 1,
+ DENSE_FEATURE_HEIGHT = 3,
+ SQUISH_FEATURE_HEIGHT = 3,
+ PACK_FEATURE_HEIGHT = 9,
+ LABEL_SPACING = 2,
+ PACK_SPACING = 5,
+ MAX_FEATURE_DEPTH = 100,
+ CONNECTOR_COLOR = "#ccc";
+
var LinkedFeaturePainter = function( data, view_start, view_end, prefs, mode ) {
FeaturePainter.call( this, data, view_start, view_end, prefs, mode );
}
@@ -2889,7 +2906,7 @@
// No details for feature, so only one way to display.
ctx.fillStyle = block_color;
// TODO: what should width be here?
- ctx.fillRect(f_start, y_center + 5, f_end - f_start, DENSE_FEATURE_HEIGHT);
+ ctx.fillRect(f_start, y_center + 5, f_end - f_start, NO_DETAIL_FEATURE_HEIGHT);
}
else { // Mode is either Squish or Pack:
// Feature details.
@@ -2918,9 +2935,9 @@
// If there are no blocks, treat the feature as one big exon.
if ( feature.strand ) {
if (feature.strand === "+") {
- ctx.fillStyle = RIGHT_STRAND_INV;
+ ctx.fillStyle = ctx.canvas.manager.get_pattern( 'right_strand_inv' );
} else if (feature.strand === "-") {
- ctx.fillStyle = LEFT_STRAND_INV;
+ ctx.fillStyle = ctx.canvas.manager.get_pattern( 'left_strand_inv' );
}
}
else { // No strand.
@@ -2947,9 +2964,9 @@
var cur_y_center = y_center;
var cur_height = thick_height;
if (feature_strand === "+") {
- ctx.fillStyle = RIGHT_STRAND;
+ ctx.fillStyle = ctx.canvas.manager.get_pattern( 'right_strand' );
} else if (feature_strand === "-") {
- ctx.fillStyle = LEFT_STRAND;
+ ctx.fillStyle = ctx.canvas.manager.get_pattern( 'left_strand' );
}
}
else {
@@ -3266,9 +3283,10 @@
type = item["type"];
data = item["data"];
if (type === "text") {
- ctx.font = "bold " + DEFAULT_FONT;
+ ctx.save();
+ ctx.font = "bold " + ctx.font;
ctx.fillText(data[0], data[1], data[2]);
- ctx.font = DEFAULT_FONT;
+ ctx.restore();
}
else if (type == "triangle") {
drawDownwardEquilateralTriangle(ctx, data[0], data[1], data[2]);
http://bitbucket.org/galaxy/galaxy-central/changeset/ea3fa74b93ff/
changeset: r5324:ea3fa74b93ff
user: james_taylor
date: 2011-04-02 19:01:25
summary: trackster: thick region should not be drawn when thick_stat == thick_end (this indicates no thick region). Non-coding genes draw correctly now
affected #: 1 file (124 bytes)
--- a/static/scripts/trackster.js Sat Apr 02 12:20:22 2011 -0400
+++ b/static/scripts/trackster.js Sat Apr 02 13:01:25 2011 -0400
@@ -2992,7 +2992,8 @@
block_end - block_start, thin_height);
// If block intersects with thick region, draw block as thick.
- if (thick_start !== undefined && !(block_start > thick_end || block_end < thick_start) ) {
+ // - No thick is sometimes encoded as thick_start == thick_end, so don't draw in that case
+ if (thick_start !== undefined && feature_te > feature_ts && !(block_start > thick_end || block_end < thick_start) ) {
var block_thick_start = Math.max(block_start, thick_start),
block_thick_end = Math.min(block_end, thick_end);
ctx.fillRect(block_thick_start, y_center + 1,
http://bitbucket.org/galaxy/galaxy-central/changeset/b559033acfc3/
changeset: r5325:b559033acfc3
user: james_taylor
date: 2011-04-02 19:02:43
summary: trackster: fixing tabs again
affected #: 1 file (154 bytes)
--- a/static/scripts/trackster.js Sat Apr 02 13:01:25 2011 -0400
+++ b/static/scripts/trackster.js Sat Apr 02 13:02:43 2011 -0400
@@ -32,12 +32,12 @@
CanvasManager.prototype.load_pattern = function( key, path ) {
var patterns = this.patterns,
- dummy_context = this.dummy_context,
+ dummy_context = this.dummy_context,
image = new Image();
// FIXME: where does image_path come from? not in browser.mako...
image.src = image_path + path;
image.onload = function() {
- patterns[key] = dummy_context.createPattern( image, "repeat" );
+ patterns[key] = dummy_context.createPattern( image, "repeat" );
}
}
@@ -2147,14 +2147,14 @@
};
$.extend(FeatureTrack.prototype, TiledTrack.prototype, {
update_auto_mode: function( mode ) {
- if ( this.mode == "Auto" ) {
- if ( mode == "no_detail" ) {
- mode = "reduced to feature spans";
- } else if ( mode == "summary_tree" ) {
- mode = "reduced to foverage histogram";
- }
- this.mode_div.text( "Auto (" + mode + ")" );
- }
+ if ( this.mode == "Auto" ) {
+ if ( mode == "no_detail" ) {
+ mode = "reduced to feature spans";
+ } else if ( mode == "summary_tree" ) {
+ mode = "reduced to foverage histogram";
+ }
+ this.mode_div.text( "Auto (" + mode + ")" );
+ }
},
/**
* Place features in slots for drawing (i.e. pack features).
@@ -2169,7 +2169,7 @@
// need to create new slots.
var dummy_context = this.view.canvas_manager.dummy_context,
- inc_slots = this.inc_slots[level];
+ inc_slots = this.inc_slots[level];
if (!inc_slots || (inc_slots.mode !== mode)) {
inc_slots = new FeatureSlotter( level, mode === "Pack", function ( x ) { return dummy_context.measureText( x ) } );
inc_slots.mode = mode;
@@ -2217,7 +2217,7 @@
mode = "Pack";
}
}
- this.update_auto_mode( mode );
+ this.update_auto_mode( mode );
}
// Drawing the summary tree (feature coverage histogram)
@@ -2710,16 +2710,16 @@
// Line at 0.0
if ( mode !== "Intensity" ) {
- /*
+ /*
ctx.beginPath();
ctx.moveTo( 0, y_zero );
ctx.lineTo( width, y_zero );
// ctx.lineWidth = 0.5;
ctx.fillStyle = "#aaa";
ctx.stroke();
- */
- ctx.fillStyle = "#aaa";
- ctx.fillRect( 0, y_zero, width, 1 );
+ */
+ ctx.fillStyle = "#aaa";
+ ctx.fillRect( 0, y_zero, width, 1 );
}
ctx.beginPath();
@@ -2992,7 +2992,7 @@
block_end - block_start, thin_height);
// If block intersects with thick region, draw block as thick.
- // - No thick is sometimes encoded as thick_start == thick_end, so don't draw in that case
+ // - No thick is sometimes encoded as thick_start == thick_end, so don't draw in that case
if (thick_start !== undefined && feature_te > feature_ts && !(block_start > thick_end || block_end < thick_start) ) {
var block_thick_start = Math.max(block_start, thick_start),
block_thick_end = Math.min(block_end, thick_end);
@@ -3284,7 +3284,7 @@
type = item["type"];
data = item["data"];
if (type === "text") {
- ctx.save();
+ ctx.save();
ctx.font = "bold " + ctx.font;
ctx.fillText(data[0], data[1], data[2]);
ctx.restore();
http://bitbucket.org/galaxy/galaxy-central/changeset/7cfd76491f25/
changeset: r5326:7cfd76491f25
user: james_taylor
date: 2011-04-02 19:34:08
summary: trackster: draw inverted fishbones for genes with UTRs but no introns (one block with meaningful thick region)
affected #: 1 file (703 bytes)
--- a/static/scripts/trackster.js Sat Apr 02 13:02:43 2011 -0400
+++ b/static/scripts/trackster.js Sat Apr 02 13:34:08 2011 -0400
@@ -2995,9 +2995,24 @@
// - No thick is sometimes encoded as thick_start == thick_end, so don't draw in that case
if (thick_start !== undefined && feature_te > feature_ts && !(block_start > thick_end || block_end < thick_start) ) {
var block_thick_start = Math.max(block_start, thick_start),
- block_thick_end = Math.min(block_end, thick_end);
+ block_thick_end = Math.min(block_end, thick_end);
ctx.fillRect(block_thick_start, y_center + 1,
block_thick_end - block_thick_start, thick_height);
+ if ( feature_blocks.length == 1 ) {
+ // Exactly one block means we have no introns, but do have a distinct "thick" region
+ if (feature_strand === "+") {
+ ctx.fillStyle = ctx.canvas.manager.get_pattern( 'right_strand_inv' );
+ } else if (feature_strand === "-") {
+ ctx.fillStyle = ctx.canvas.manager.get_pattern( 'left_strand_inv' );
+ }
+ // If region is wide enough in pixels, pad a bit
+ if ( block_thick_start + 14 < block_thick_end ) {
+ block_thick_start += 2;
+ block_thick_end -= 2;
+ }
+ ctx.fillRect( block_thick_start, y_center + 1,
+ block_thick_end - block_thick_start, thick_height );
+ }
}
}
}
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: james_taylor: trackster: making extensions to CanvasRenderingContext regular functions, extending built-ins is verboten, breaks encapsulation
by Bitbucket 02 Apr '11
by Bitbucket 02 Apr '11
02 Apr '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/30f45fb80386/
changeset: r5322:30f45fb80386
user: james_taylor
date: 2011-04-02 16:05:24
summary: trackster: making extensions to CanvasRenderingContext regular functions, extending built-ins is verboten, breaks encapsulation
affected #: 1 file (64 bytes)
--- a/static/scripts/trackster.js Fri Apr 01 18:10:47 2011 -0400
+++ b/static/scripts/trackster.js Sat Apr 02 10:05:24 2011 -0400
@@ -8,7 +8,7 @@
* However, that approach uses lines, which don't seem to render as well, so use
* rectangles instead.
*/
-CanvasRenderingContext2D.prototype.dashedLine = function(x1, y1, x2, y2, dashLen) {
+var dashedLine = function(ctx, x1, y1, x2, y2, dashLen) {
if (dashLen === undefined) { dashLen = 4; }
var dX = x2 - x1;
var dY = y2 - y1;
@@ -21,14 +21,14 @@
if (q % 2 !== 0) {
continue;
}
- this.fillRect(x1, y1, dashLen, 1);
+ ctx.fillRect(x1, y1, dashLen, 1);
}
};
/**
* Draw an isosceles triangle that points down.
*/
-CanvasRenderingContext2D.prototype.drawDownwardEquilateralTriangle = function(down_vertex_x, down_vertex_y, side_len) {
+var drawDownwardEquilateralTriangle = function(ctx, down_vertex_x, down_vertex_y, side_len) {
// Compute other two points of triangle.
var
x1 = down_vertex_x - side_len/2,
@@ -36,16 +36,16 @@
y = down_vertex_y - Math.sqrt( side_len*3/2 );
// Draw and fill.
- this.beginPath();
- this.moveTo(x1, y);
- this.lineTo(x2, y);
- this.lineTo(down_vertex_x, down_vertex_y);
- this.lineTo(x1, y);
+ ctx.beginPath();
+ ctx.moveTo(x1, y);
+ ctx.lineTo(x2, y);
+ ctx.lineTo(down_vertex_x, down_vertex_y);
+ ctx.lineTo(x1, y);
- this.strokeStyle = this.fillStyle;
- this.fill();
- this.stroke();
- this.closePath();
+ ctx.strokeStyle = this.fillStyle;
+ ctx.fill();
+ ctx.stroke();
+ ctx.closePath();
};
/**
@@ -3271,7 +3271,7 @@
ctx.font = DEFAULT_FONT;
}
else if (type == "triangle") {
- ctx.drawDownwardEquilateralTriangle(data[0], data[1], data[2]);
+ drawDownwardEquilateralTriangle(ctx, data[0], data[1], data[2]);
}
}
},
@@ -3317,7 +3317,7 @@
// Draw connector.
if (b2_start > b1_end) {
ctx.fillStyle = CONNECTOR_COLOR;
- ctx.dashedLine(b1_end - gap, y_center + 5, b2_start - gap, y_center + 5);
+ dashedLine(ctx, b1_end - gap, y_center + 5, b2_start - gap, y_center + 5);
}
} else {
// Read is single.
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