ee211bfbeedc99ca157c71ba3ba04ae6346b263b max Tue Jul 21 02:11:14 2020 -0700 support the super old chrom:start-end syntax again (found by Jonathan), adding back possibility to have higlights on two different dbs by removing check for db-prefix in hgTracks (the db-filtering is done by the javascript code anyways) and clean up the code a little by introducing a function that creates the highlight string from the parts instead of copied code. refs #21384 diff --git src/hg/js/utils.js src/hg/js/utils.js index dbc2db0..bda910a 100644 --- src/hg/js/utils.js +++ src/hg/js/utils.js @@ -1151,62 +1151,72 @@ { if (position && position.length > 0) { position = position.replace(/,/g, ""); var a = /(\S+):(\d+)-(\d+)/.exec(position); if (a && a.length === 4) { var o = {}; o.chrom = a[1]; o.start = parseInt(a[2]); o.end = parseInt(a[3]); return o; } } return null; } +function makeHighlightString(db, chrom, start, end, color) { +/* given db and a range on it and a color (color must be prefixed by #), + * return the highlight string in the cart for it. See parsePositionWithDb for the history + * of the various accepted highlight strings */ + return db+"#"+chrom+"#"+start+"#"+end+color; +} + function parsePositionWithDb(position) // returns an object with chrom, start, end and optionally color attributes // position is a string and can be in one of five different formats: // 0) chr:start-end // 1) db.chr:start-end // 2) db.chr:start-end#color -// 4) db#chr#start#end#color +// 3) db#chr#start#end#color // Formats 0-2 are only supported for backwards compatibility with old carts -// Original comment: Is this ever used when the db isn't the same one as getDb() would return? { var out = {}; var parts = null; if (position.split("#").length !==5 ) { + // formats of old carts: 0-2 parts = position.split("."); + // handle the db part if (parts.length === 2) { out.db = parts[0]; position = parts[1]; } else { out.db = getDb(); // default the db } + // position now contains chr:start-end#color parts = position.split("#"); // Highlight Region may carry its color if (parts.length === 2) { position = parts[0]; out.color = '#' + parts[1]; } var pos = parsePosition(position); if (pos) { out.chrom = pos.chrom; out.start = pos.start; out.end = pos.end; } } else { + // new format parts = position.split("#"); out.db = parts[0]; out.chrom = parts[1]; out.start = parts[2]; out.end = parts[3]; out.color = "#" + parts[4]; } return out; } function getSizeFromCoordinates(position) { // Parse size out of a chr:start-end string var o = parsePosition(position); if (o) {