35b3c483895c5ee49ad380200a342db959da6d3f kate Thu Mar 4 17:07:25 2021 -0800 Add multi-region mode and improve layout a bit on position box popup. refs #26385 diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js index 62e9a3c..866047a 100644 --- src/hg/js/hgTracks.js +++ src/hg/js/hgTracks.js @@ -554,62 +554,76 @@ }, positionDisplayDialog: function () // Show the virtual and real positions of the windows { var position = genomePos.get(); position.replace("virt:", "multi:"); var positionDialog = $("#positionDialog")[0]; if (!positionDialog) { $("body").append("<div id='positionDialog'><span id='positionDisplayPosition'></span>"); positionDialog = $("#positionDialog")[0]; } if (hgTracks.windows) { var i, len, end; var matches = /^multi:[0-9]+-([0-9]+)/.exec(position); - var str = position; + var modeType = (hgTracks.virtModeType === "customUrl" ? "Custom regions on virtual chromosome" : + (hgTracks.virtModeType === "exonMostly" ? "Exon view of" : + (hgTracks.virtModeType === "geneMostly" ? "Gene view of" : + (hgTracks.virtModeType === "singleAltHaplo" ? "Alternate haplotype as virtual chromosome" : + "Unknown mode")))); + var str = modeType + " " + position; if (matches) { end = matches[1]; if (end < hgTracks.chromEnd) { str += "<br>(full virtual region is multi:1-" + hgTracks.chromEnd + ")"; } } if (!(hgTracks.virtualSingleChrom && (hgTracks.windows.length === 1))) { - str += "<br>\n"; - str += "<br>\n"; - str += "<ul style='list-style-type:none; max-height:200px; padding:0; width:80%; overflow:hidden; overflow-y:scroll;'>\n"; + var w; + if (hgTracks.windows.length <= 10) { + str += "<p><table>\n"; for (i=0,len=hgTracks.windows.length; i < len; ++i) { - var w = hgTracks.windows[i]; + w = hgTracks.windows[i]; + str += "<tr><td>" + w.chromName + ":" + (w.winStart+1) + "-" + w.winEnd + "</td><td>" + + (w.winEnd - w.winStart) + " bp" + "</td></tr>\n"; + } + str += "</table></p>\n"; + } else { + str += "<br><ul style='list-style-type:none; max-height:200px; padding:0; width:80%; overflow:hidden; overflow-y:scroll;'>\n"; + for (i=0,len=hgTracks.windows.length; i < len; ++i) { + w = hgTracks.windows[i]; str += "<li>" + w.chromName + ":" + (w.winStart+1) + "-" + w.winEnd + " " + (w.winEnd - w.winStart) + " bp" + "</li>\n"; } str += "</ul>\n"; } + } $("#positionDisplayPosition").html(str); } else { $("#positionDisplayPosition").html(position); } $(positionDialog).dialog({ modal: true, - title: "Multi-region position ranges", + title: "Multi-Region Position Ranges", closeOnEscape: true, resizable: false, autoOpen: false, minWidth: 400, minHeight: 40, buttons: { - "OK": function() { + "exit multi-region mode": function() { $(this).dialog("close"); } }, open: function () { // Make OK the focus/default action $(this).parents('.ui-dialog-buttonpane button:eq(0)').focus(); }, close: function() { // All exits to dialog should go through this $(imageV2.imgTbl).imgAreaSelect({hide:true}); $(this).hide(); $('body').css('cursor', ''); // Occasionally wait cursor got left behind } }); @@ -3334,31 +3348,31 @@ html = '<span class="shortcut">t s</span>'; $('#trackSearchMenuLink').after(html); html = '<span class="shortcut">c f</span>'; $('#configureMenuLink').after(html); html = '<span class="shortcut">c r</span>'; $('#cartResetMenuLink').after(html); } // A function for the keyboard shortcut: // View DNA function gotoGetDnaPage() { var position = hgTracks.chromName+":"+hgTracks.winStart+"-"+hgTracks.winEnd; - if (hgTracks.virtualSingleChrom && (pos.chrom.search("virt") === 0)) { + if (hgTracks.virtualSingleChrom && (pos.chrom.search("multi") === 0)) { position = genomePos.get().replace(/,/g,''); } else if (hgTracks.windows && hgTracks.nonVirtPosition) { position = hgTracks.nonVirtPosition; } var pos = parsePosition(position); if (pos) { var url = "hgc?hgsid="+getHgsid()+"&g=getDna&i=mixed&c="+pos.chrom+"&l="+pos.start+"&r="+pos.end+"&db="+getDb(); window.location.href = url; } return false; } // A function for the keyboard shortcuts "zoom to x bp" function zoomTo(zoomSize) { var flankSize = Math.floor(zoomSize/2); @@ -4225,46 +4239,46 @@ error: errorHandler, cmd: 'wholeImage', loadingId: showLoadingImage("imgTbl"), disabledEle: disabledEle, currentId: currentId, currentIdYOffset: currentIdYOffset, cache: false }); }, disguiseHighlight: function(position) // disguise highlight position { pos = parsePositionWithDb(position); // DISGUISE - if (hgTracks.virtualSingleChrom && (pos.chrom.search("virt") === 0)) { + if (hgTracks.virtualSingleChrom && (pos.chrom.search("multi") === 0)) { var positionStr = pos.chrom+":"+pos.start+"-"+pos.end; var newPosition = genomePos.disguisePosition(positionStr); var newPos = parsePosition(newPosition); pos.chrom = newPos.chrom; pos.start = newPos.start; pos.end = newPos.end; } return makeHighlightString(pos.db, pos.chrom, pos.start, pos.end, pos.color); }, undisguiseHighlight: function(pos) // undisguise highlight pos { // UN-DISGUISE - if (hgTracks.virtualSingleChrom && (pos.chrom.search("virt") !== 0)) { + if (hgTracks.virtualSingleChrom && (pos.chrom.search("multi") !== 0)) { var position = pos.chrom+":"+pos.start+"-"+pos.end; var newPosition = genomePos.undisguisePosition(position); var newPos = parsePosition(newPosition); if (newPos) { pos.chrom = newPos.chrom; pos.start = newPos.start; pos.end = newPos.end; } } }, highlightRegion: function() // highlight vertical region in imgTbl based on hgTracks.highlight (#709). { var pos;