2c9786155a4a3134fdef9c08b03148f1b9c988ec max Thu Jul 16 06:11:45 2020 -0700 fixing highlight problems with chrom names that contain a period or colon, #25887 diff --git src/hg/js/utils.js src/hg/js/utils.js index ad25c78..dbc2db0 100644 --- src/hg/js/utils.js +++ src/hg/js/utils.js @@ -1152,56 +1152,69 @@ 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 parsePositionWithDb(position) -// Parse db.chr:start-end string into a db, chrom, start, end object -// Also supports be db.chr:start-end#color string -// Doesn't work right with db's with '.'s in them. Is this ever -// used when the db isn't the same one as getDb() would return? +// 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 +// 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 = position.split("."); + var parts = null; + if (position.split("#").length !==5 ) { + parts = position.split("."); if (parts.length === 2) { out.db = parts[0]; position = parts[1]; } else { out.db = getDb(); // default the db } 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; - return out; } - return null; + } else { + 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) { return o.end - o.start + 1; } return null; } // This code is intended to allow setting up a wait cursor while waiting on the function var gWaitFuncArgs = []; var gWaitFunc;