be1a77e1e634b439617d8c04195a5ce90ae93e0d
galt
Wed Feb 24 13:15:15 2016 -0800
Removing DEBUG warnings from hgTracks.js multi-region code.
diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js
index 6a746cd..4d4d39e 100644
--- src/hg/js/hgTracks.js
+++ src/hg/js/hgTracks.js
@@ -125,159 +125,147 @@
getOriginalPos: function ()
{
return genomePos.original || genomePos.get();
},
revertToOriginalPos: function ()
{
// undo changes to position (i.e. after user aborts a drag-and-select).
this.set(this.original, this.originalSize);
this.original = this.originalSize = null; // not sure if this is necessary.
},
undisguisePosition: function(position) // UN-DISGUISE VMODE
{ // find the virt position
// position should be real chrom span
- //warn("undisguisePosition position="+position); // DEBUG REMOVE
var pos = parsePosition(position);
if (!pos)
return position; // some parsing error, return original
var start = pos.start - 1;
var end = pos.end;
var chromName = hgTracks.windows[0].chromName;
if (pos.chrom !== chromName)
return position; // return original
var newStart = -1;
var newEnd = -1;
var lastW = null;
var windows = null;
- //warn("start="+start+" end="+end); // DEBUG REMOVE
for (j=0; j < 3; ++j) {
if (j === 0) windows = hgTracks.windowsBefore;
if (j === 1) windows = hgTracks.windows;
if (j === 2) windows = hgTracks.windowsAfter;
for (i=0,len=windows.length; i < len; ++i) {
var w = windows[i];
// double check chrom is same thoughout all windows, otherwise warning, return original value
if (w.chromName != chromName) {
return position; // return original
}
// check that the regions are ascending and non-overlapping
if (lastW && w.winStart < lastW.winEnd) {
return position; // return original
}
// overlap with position?
// if intersection,
if (w.winEnd > start && end > w.winStart) {
var s = Math.max(start, w.winStart);
var e = Math.min(end, w.winEnd);
var cs = s - w.winStart + w.virtStart;
var ce = e - w.winStart + w.virtStart;
- //warn("cs="+cs+" ce="+ce); // DEBUG REMOVE
if (newStart === -1)
newStart = cs;
newEnd = ce;
}
lastW = w;
}
}
// return new virt undisguised position as a string
var newPos = "virt:" + (newStart+1) + "-" + newEnd;
- //warn("undisguisePosition newPos="+newPos); // DEBUG REMOVE
return newPos;
},
disguiseSize: function(position) // DISGUISE VMODE
{ // find the real size of the windows spanned
// position should be a real chrom span
- //warn("disguisePosition position="+position); // DEBUG REMOVE
var pos = parsePosition(position);
if (!pos)
return 0;
var start = pos.start - 1;
var end = pos.end;
var newSize = 0;
var windows = null;
- //warn("start="+start+" end="+end); // DEBUG REMOVE
for (j=0; j < 3; ++j) {
if (j === 0) windows = hgTracks.windowsBefore;
if (j === 1) windows = hgTracks.windows;
if (j === 2) windows = hgTracks.windowsAfter;
for (i=0,len=windows.length; i < len; ++i) {
var w = windows[i];
// overlap with position?
// if intersection,
if (w.winEnd > start && end > w.winStart) {
var s = Math.max(start, w.winStart);
var e = Math.min(end, w.winEnd);
- //warn("s="+s+" e="+e); // DEBUG REMOVE
newSize += (e - s);
}
}
}
// return real size of the disguised position
- //warn("disguiseSize newSize="+newSize); // DEBUG REMOVE
return newSize;
},
disguisePosition: function(position) // DISGUISE VMODE
{ // find the single-chrom range spanned
// position should be virt
- //warn("disguisePosition position="+position); // DEBUG REMOVE
var pos = parsePosition(position);
if (!pos)
return position; // some parsing error, return original
var start = pos.start - 1;
var end = pos.end;
var chromName = hgTracks.windows[0].chromName;
var newStart = -1;
var newEnd = -1;
var lastW = null;
var windows = null;
- //warn("start="+start+" end="+end); // DEBUG REMOVE
for (j=0; j < 3; ++j) {
if (j === 0) windows = hgTracks.windowsBefore;
if (j === 1) windows = hgTracks.windows;
if (j === 2) windows = hgTracks.windowsAfter;
for (i=0,len=windows.length; i < len; ++i) {
var w = windows[i];
// double check chrom is same thoughout all windows, otherwise warning, return original value
if (w.chromName != chromName) {
return position; // return undisguised original
}
// check that the regions are ascending and non-overlapping
if (lastW && w.winStart < lastW.winEnd) {
return position; // return undisguised original
}
// overlap with position?
// if intersection,
if (w.virtEnd > start && end > w.virtStart) {
var s = Math.max(start, w.virtStart);
var e = Math.min(end, w.virtEnd);
var cs = s - w.virtStart + w.winStart;
var ce = e - w.virtStart + w.winStart;
- //warn("cs="+cs+" ce="+ce); // DEBUG REMOVE
if (newStart === -1)
newStart = cs;
newEnd = ce;
}
lastW = w;
}
}
// return new non-virt disguised position as a string
var newPos = chromName + ":" + (newStart+1) + "-" + newEnd;
- //warn("disguisePosition newPos="+newPos); // DEBUG REMOVE
return newPos;
},
set: function (position, size)
{ // Set value of position and size (in hiddens and input elements).
// We assume size has already been commified.
// Either position or size may be null.
// stack dump // DEBUG
//console.trace();
// NOT work on safari
//var obj = {};
//Error.captureStackTrace(obj);
//warn("genomePos.set() called "+obj.stack);
@@ -410,53 +398,49 @@
var newStart = hgTracks.winStart + startDelta;
var newEnd = hgTracks.winStart + 1 + endDelta;
if (newEnd > winEnd) {
newEnd = winEnd;
}
return {chromStart : newStart, chromEnd : newEnd};
},
chromToVirtChrom: function (chrom, chromStart, chromEnd)
{ // Convert regular chromosome position to virtual chrom coordinates using hgTracks.windows list
// Consider the first contiguous set of overlapping regions to define the match (for now).
// only works for regions covered by the current hgTracks.windows
var virtStart = -1, virtEnd = -1;
var s,e;
var i, len;
- //warn("length of hgTracks.windows = "+hgTracks.windows.length); // DEBUG REMOVE
for (i = 0, len = hgTracks.windows.length; i < len; ++i) {
var w = hgTracks.windows[i];
var overlap = (chrom == w.chromName && chromEnd > w.winStart && w.winEnd > chromStart);
- //warn("w.chromName="+w.chromName+" w.winStart="+w.winStart+" w.winEnd="+w.winEnd+" overlap?="+overlap+" virtStart="+virtStart); // DEBUG REMOVE
if (virtStart == -1) {
if (overlap) {
// when they overlap the first time
s = Math.max(chromStart, w.winStart);
e = Math.min(chromEnd, w.winEnd);
virtStart = w.virtStart + (s - w.winStart);
virtEnd = w.virtStart + (e - w.winStart);
- //warn("s="+s+" e="+e+" virtStart="+virtStart+" virtEnd="+virtEnd); // DEBUG REMOVE
} else {
// until they overlap
// do nothing
}
} else {
if (overlap) {
// while they continue to overlap, extend
e = Math.min(chromEnd, w.winEnd);
virtEnd = w.virtStart + (e - w.winStart);
- //warn("extend virtEnd="+virtEnd); // DEBUG REMOVE
} else {
// when they do not overlap anymore, stop
break;
}
}
}
return {chromStart : virtStart, chromEnd : virtEnd};
},
selectionPixelsToBases: function (img, selection)
{ // Convert selection x1/x2 coordinates to chromStart/chromEnd.
return genomePos.pixelsToBases(img, selection.x1, selection.x2,
hgTracks.winStart, hgTracks.winEnd);
},
@@ -531,31 +515,30 @@
url: "../cgi-bin/hgTracks",
data: cart.varsToUrlData({ 'hgt.convertChromToVirtChrom': pos, 'hgt.trackImgOnly' : 1, 'hgsid': getHgsid() }),
dataType: "html",
trueSuccess: genomePos.handleConvertChromPosToVirtCoords,
success: catchErrorOrDispatch,
error: errorHandler,
cache: false
});
return genomePos.convertedVirtCoords;
},
positionDisplayDialog: function ()
// Show the virtual and real positions of the windows
{
var position = genomePos.get();
- //warn("positionDisplayDialog position="+position); // DEBUG REMOVE
var positionDialog = $("#positionDialog")[0];
if (!positionDialog) {
$("body").append("
");
positionDialog = $("#positionDialog")[0];
}
if (hgTracks.windows) {
var i,len;
var str = position;
if (!(hgTracks.virtualSingleChrom && (hgTracks.windows.length === 1))) {
str += "
\n";
str += "
\n";
str += "
\n";
for (i=0,len=hgTracks.windows.length; i < len; ++i) {
var w = hgTracks.windows[i];
str += "- " + w.chromName + ":" + (w.winStart+1) + "-" + w.winEnd + "
\n";
@@ -1007,31 +990,30 @@
genomePos.update(img, selection, false);
jQuery('body').css('cursor', dragSelect.originalCursor);
} else {
jQuery('body').css('cursor', 'not-allowed');
}
}
return true;
},
highlightThisRegion: function(newPosition)
// set highlighting newPosition in server-side cart and apply the highlighting in local UI.
{
var pos = parsePosition(newPosition);
var start = pos.start;
var end = pos.end;
- //warn("highlightThisRegion: newPosition="+newPosition); // DEBUG REMOVE
hgTracks.highlight = getDb() + "." + pos.chrom + ":" + start + "-" + end + '#AAFFFF';
hgTracks.highlight = imageV2.disguiseHighlight(hgTracks.highlight);
// we include enableHighlightingDialog because it may have been changed by the dialog
var cartSettings = { 'highlight': hgTracks.highlight,
'enableHighlightingDialog': hgTracks.enableHighlightingDialog ? 1 : 0 };
if (hgTracks.windows && !hgTracks.virtualSingleChrom) {
var nonVirtChrom = "";
var nonVirtStart = -1;
var nonVirtEnd = -1;
for (i=0,len=hgTracks.windows.length; i < len; ++i) {
var w = hgTracks.windows[i];
// overlap with new position?
if (w.virtEnd > start && end > w.virtStart) {
var s = Math.max(start, w.virtStart);
@@ -2442,37 +2424,35 @@
chromEnd = parseInt(a[1]);
}
if (!chrom || chrom.length === 0 || !chromStart || !chromEnd) {// 1-based chromStart
warn("couldn't parse out genomic coordinates");
} else {
if (cmd === 'getDna') {
// NOTE: this should be shared with URL generation for getDna blue bar menu
url = "../cgi-bin/hgc?g=getDna&i=mixed&c=" + chrom;
url += "&l=" + (chromStart - 1) + "&r=" + chromEnd;
url += "&db=" + getDb() + "&hgsid=" + getHgsid();
if ( ! window.open(url) ) {
rightClick.windowOpenFailedMsg();
}
} else if (cmd === 'highlightItem') {
if (hgTracks.windows && !hgTracks.virtualSingleChrom) {
- //warn("hitFinish highlightItem chrom="+chrom+" chromStart="+chromStart+" chromEnd="+chromEnd); // DEBUG REMOVE
// orig way only worked if the entire item was visible in the windows.
//var result = genomePos.chromToVirtChrom(chrom, parseInt(chromStart-1), parseInt(chromEnd));
var result = genomePos.convertChromPosToVirtCoords(chrom, parseInt(chromStart-1), parseInt(chromEnd));
- //warn("result.chromStart="+result.chromStart+" result.chromEnd="+result.chromEnd); // DEBUG REMOVE
if (result.chromStart != -1)
{
var newPos2 = hgTracks.chromName+":"+(result.chromStart+1)+"-"+result.chromEnd;
dragSelect.highlightThisRegion(newPos2);
}
} else {
var newChrom = hgTracks.chromName;
if (hgTracks.windows && hgTracks.virtualSingleChrom) {
newChrom = hgTracks.windows[0].chromName;
}
var newPos3 = newChrom+":"+(parseInt(chromStart))+"-"+parseInt(chromEnd);
dragSelect.highlightThisRegion(newPos3);
}
} else {
@@ -3213,32 +3193,30 @@
},
uiDialog: function (response, status)
{
// Take html from hgTracks and put it up as a modal dialog.
// make sure all links (e.g. help links) open up in a new window
response = response.replace(/"+ cleanHtml +"
");
// Strategy for popups with js:
// - jsFiles and CSS should not be included in html. Here they are shluped out.
// - The resulting files ought to be loadable dynamically (with getScript()),
// but this was not working nicely with the modal dialog
// Therefore include files must be included with hgTracks CGI !
// - embedded js should not be in the popup box.
// - Somethings should be in a popup.ready() function, and this is emulated below,
// as soon as the cleanHtml is added
// Since there are many possible popup cfg dialogs, the ready should be all inclusive.
// -- popup.ready() -- Here is the place to do things that might otherwise go
// into a $('#pop').ready() routine!
@@ -3384,31 +3362,31 @@
var allVars = getAllVars($('#hgTrackUiDialog'), subtrack );
// Since 2010, when Tim changed this to only report changed vars instead of all form vars,
// it no longer matches the behavior of hgTrackUi when called the non-popup way.
// A few places in the hgTracks C code have been patched to explicitly set the cart vars
// for some default checkboxes. So now this still means that QA must explicitly test
// both paths through the code: as a separate full hgTracksUi page, and as a popup config window.
// hgTrackUi always sends in its form all variables causing them to be explicitly set in the cart.
// The popup only sends things that have changed, causing those changes to appear explicitly
// and even then it skips over disabled form items.
// There is some C code that was written before the popup config,
// and it expects all the variables are set or none are.
// If just some are set, and not the default ones, it gets confused.
// I fixed just such a bug in the code that handles refSeq.
// See commit daf92c0f9eb331ea60740e6802aabd241d4be363.
var changedVars = varHashChanges(allVars,popUp.saveAllVars);
- // DEBUG REMOVE
+ // DEBUG Examples:
//debugDumpFormCollection("saveAllVars", popUp.saveAllVars);
//debugDumpFormCollection("allVars", allVars);
//debugDumpFormCollection("changedVars", changedVars);
var newVis = changedVars[trackName];
// subtracks do not have "hide", thus '[]'
var hide = (newVis && (newVis === 'hide' || newVis === '[]'));
if ( ! normed($('#imgTbl')) ) { // On findTracks or config page
if (objNotEmpty(changedVars))
cart.setVarsObj(changedVars);
}
else { // On image page
if (hide) {
if (objNotEmpty(changedVars))
cart.setVarsObj(changedVars);
$(document.getElementById('tr_' + trackName)).remove();
@@ -3861,39 +3839,35 @@
else
url += '&' + extraData;
}
window.location.assign(url);
return false;
}
document.TrackHeaderForm.submit();
},
updateImgAndMap: function (response, status)
{ // Handle ajax response with an updated trackMap image, map and optional ideogram.
// and maybe the redLines background too.
// this.cmd can be used to figure out which menu item triggered this.
// this.id === appropriate track if we are retrieving just a single track.
- //warn("updateImgAndMap got here 0"); // DEBUG REMOVE GALT
-
// update local hgTracks.trackDb to reflect possible side-effects of ajax request.
- //alert(response); //DEBUG REMOVE GALT
-
var newJson = scrapeVariable(response, "hgTracks");
- //alert(JSON.stringify(newJson)); // DEBUG REMOVE GALT
+ //alert(JSON.stringify(newJson)); // DEBUG Example
var oldJson = hgTracks;
var valid = false;
if (!newJson) {
var stripped = {};
stripJsEmbedded(response, true, stripped);
if ( ! stripped.warnMsg )
warn("hgTracks object is missing from the response");
} else {
if (this.id) {
if (newJson.trackDb[this.id]) {
var visibility = vis.enumOrder[newJson.trackDb[this.id].visibility];
var limitedVis;
if (newJson.trackDb[this.id].limitedVis)
limitedVis = vis.enumOrder[newJson.trackDb[this.id].limitedVis];
@@ -4142,54 +4116,50 @@
if (hgTracks.virtualSingleChrom && (pos.chrom.search("virt") === 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 pos.db+"."+pos.chrom+":"+pos.start+"-"+pos.end+pos.color;
},
undisguiseHighlight: function(pos)
// undisguise highlight pos
{
// UN-DISGUISE
- //console.warn("undisguiseHighlight: got here 0"); // DEBUG REMOVE
if (hgTracks.virtualSingleChrom && (pos.chrom.search("virt") !== 0)) {
var position = pos.chrom+":"+pos.start+"-"+pos.end;
var newPosition = genomePos.undisguisePosition(position);
- //console.warn("undisguiseHighlight: newPosition="+newPosition); // DEBUG REMOVE
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;
var hexColor = '#FFAAAA';
$('#highlightItem').remove();
if (hgTracks.highlight) {
- //console.warn("highlightRegion: hgTracks.highlight="+hgTracks.highlight); // DEBUG REMOVE
pos = parsePositionWithDb(hgTracks.highlight);
- //console.warn("highlightRegion: pos.chrom="+pos.chrom); // DEBUG REMOVE
// UN-DISGUISE
imageV2.undisguiseHighlight(pos);
if (pos) {
pos.start--; // make start 0-based to match hgTracks.winStart
if (pos.color)
hexColor = pos.color;
}
}
if (pos && pos.chrom === hgTracks.chromName && pos.db === getDb()
&& pos.start <= hgTracks.imgBoxPortalEnd && pos.end >= hgTracks.imgBoxPortalStart) {
var portalWidthBases = hgTracks.imgBoxPortalEnd - hgTracks.imgBoxPortalStart;
var portal = $('#imgTbl td.tdData')[0];
var leftPixels = $(portal).offset().left + 3; // 3 for borders and cgi item calcs ??
var pixelsPerBase = ($(portal).width() - 2) / portalWidthBases;
var clippedStartBases = Math.max(pos.start, hgTracks.imgBoxPortalStart);