b763a93bef738004614cb657ccab6805f94dda8e
braney
  Thu Aug 15 19:06:39 2013 -0700
make HAL linked in by default, fix the problem with mismatched bases nothaving the right chars in them, start adding HAL to the table browser.
refs #10637

diff --git src/hg/hgTracks/snakeTrack.c src/hg/hgTracks/snakeTrack.c
index 4452ff0..553ee9e 100644
--- src/hg/hgTracks/snakeTrack.c
+++ src/hg/hgTracks/snakeTrack.c
@@ -588,31 +588,30 @@
     safef(buffer, sizeof buffer, "%d %d",sf->qStart,sf->qEnd);
     if (sx < insideX)
 	{
 	int olap = insideX - sx;
 	sx = insideX;
 	w -= olap;
 	}
     char qAddress[4096];
     if (vis == tvFull)
 	{
 	safef(qAddress, sizeof qAddress, "qName=%s&qs=%d&qe=%d&qWidth=%d",tg->itemName(tg, item),  qs, qe,  winEnd - winStart);
 	mapBoxHgcOrHgGene(hvg, s, e, sx+1, y, w-2, heightPer, tg->track,
 		    buffer, buffer, NULL, TRUE, qAddress);
 	}
     hvGfxBox(hvg, sx, y, w, heightPer, color);
-    int ow = w;
 
     // now draw the mismatches if we're at high enough resolution 
     if ((winBaseCount < 50000) && (vis == tvFull))
     {
 	char *twoBitString = trackDbSetting(tg->tdb, "twoBit");
 	static struct twoBitFile *tbf = NULL;
 	static char *lastTwoBitString = NULL;
 	static struct dnaSeq *seq = NULL;
 	static char *lastQName = NULL;
 
 	// sequence for chain snakes is in 2bit files which we cache
 	if (!isHalSnake)
 	    {
 	    if (twoBitString == NULL)
 		twoBitString = "/gbdb/hg19/hg19.2bit";
@@ -657,31 +656,34 @@
 		{
 		int misX1 = round((double)((int)si-winStart)*scale) + xOff;
 		int misX2 = round((double)((int)(si+1)-winStart)*scale) + xOff;
 		int w1 = misX2 - misX1;
 		if (w1 < 1)
 		    w1 = 1;
 
 		// mismatch!
 		hvGfxBox(hvg, misX1, y, w1, heightPer, MG_RED);
 		}
 	    }
 
 	// if we're zoomed to base level, draw sequence of mismatch
 	if (zoomedToBaseLevel)
 	    {
-	    spreadAlignString(hvg, osx, y, ow, heightPer, MG_WHITE, font, ourDna,
+	    int mysx = round((double)((int)s-winStart)*scale) + xOff;
+	    int myex = round((double)((int)e-winStart)*scale) + xOff;
+	    int myw = myex - mysx;
+	    spreadAlignString(hvg, mysx, y, myw, heightPer, MG_WHITE, font, ourDna,
 		extraSeq->dna, seqLen, TRUE, FALSE);
 	    }
 
     }
     sf->drawn = TRUE;
     tEnd = e;
     tStart = s;
     qStart = sf->qStart;
     lastY = y;
     lastLevel = sf->level;
     //lastX = x;
     }
 
 if (vis == tvDense)
     return;
@@ -937,30 +939,37 @@
     }
 hFreeConn(&conn);
 }
 
 #ifdef USE_HAL
 void halSnakeLoadItems(struct track *tg)
 {
 struct errCatch *errCatch = errCatchNew();
 if (errCatchStart(errCatch))
     {
     char *fileName = trackDbSetting(tg->tdb, "bigDataUrl");
     char *otherSpecies = trackDbSetting(tg->tdb, "otherSpecies");
     int handle = halOpenLOD(fileName);
     int needSeq = (winBaseCount < 50000) ? 1 : 0;
     struct hal_block_results_t *head = halGetBlocksInTargetRange(handle, otherSpecies, trackHubSkipHubName(database), chromName, winStart, winEnd, needSeq, 1);
+
+    // did we get any blocks from HAL
+    if (head == NULL)
+	{
+	errCatchEnd(errCatch);
+	return;
+	}
     struct hal_block_t* cur = head->mappedBlocks;
     struct linkedFeatures *lf;
     struct hash *qChromHash = newHash(5);
     struct linkedFeatures *lfList = NULL;
     char buffer[4096];
 
 #ifdef NOTNOW
     struct hal_target_dupe_list_t* targetDupeBlocks = head->targetDupeBlocks;
 
     for(;targetDupeBlocks; targetDupeBlocks = targetDupeBlocks->next)
 	{
 	printf("<br>id: %d qChrom %s\n", targetDupeBlocks->id, targetDupeBlocks->qChrom);
 	struct hal_target_range_t *range = targetDupeBlocks->tRange;
 	for(; range; range = range->next)
 	    {