4ca8ddbdf81c30c083333b469e1f12d587ea74b3
braney
  Wed Nov 6 09:22:05 2013 -0800
HAL now has the target sequence in the blocks it gives us.
diff --git src/hg/hgTracks/snakeTrack.c src/hg/hgTracks/snakeTrack.c
index c9d6f10..ed7ac8d 100644
--- src/hg/hgTracks/snakeTrack.c
+++ src/hg/hgTracks/snakeTrack.c
@@ -21,31 +21,32 @@
 #include "snakeUi.h"
 
 #include "halBlockViz.h"
 
 // this is the number of pixels used by the target self-align bar
 #define DUP_LINE_HEIGHT	4
 
 struct snakeFeature
     {
     struct snakeFeature *next;
     int start, end;			/* Start/end in browser coordinates. */
     int qStart, qEnd;			/* query start/end */
     int level;				/* level in snake */
     int orientation;			/* strand... -1 is '-', 1 is '+' */
     boolean drawn;			/* did we draw this feature? */
-    char *sequence;			/* may have sequence, or NULL */
+    char *qSequence;			/* may have sequence, or NULL */
+    char *tSequence;			/* may have sequence, or NULL */
     char *qName;			/* chrom name on other species */
     };
 
 static int snakeFeatureCmpTStart(const void *va, const void *vb)
 /* sort by start position on the target sequence */
 {
 const struct snakeFeature *a = *((struct snakeFeature **)va);
 const struct snakeFeature *b = *((struct snakeFeature **)vb);
 int diff = a->start - b->start;
 
 return diff;
 }
 
 static int snakeFeatureCmpQStart(const void *va, const void *vb)
 /* sort by start position on the query sequence */
@@ -759,67 +760,76 @@
 		    lastQName = NULL;
 		    twoBitClose(&tbf);
 		    }
 		tbf = twoBitOpen(twoBitString);
 		}
 
 	    // we're reading in the whole chrom
 	    if ((lastQName == NULL) || differentString(sf->qName, lastQName))
 		seq = twoBitReadSeqFrag(tbf, sf->qName,  0, 0);
 	    lastQName = sf->qName;
 	    lastTwoBitString = twoBitString;
 	    }
 
 	char *ourDna;
 	if (isHalSnake)
-	    ourDna = sf->sequence;
+	    ourDna = sf->qSequence;
 	else
 	    ourDna = &seq->dna[sf->qStart];
 
 	int seqLen = sf->qEnd - sf->qStart;
 	toUpperN(ourDna, seqLen);
 	if (!isHalSnake && (sf->orientation == -1))
 	    reverseComplement(ourDna,seqLen);
 
 	// get the reference sequence
+	char *refDna;
+	if (isHalSnake)
+	    {
+	    refDna = sf->tSequence;
+	    }
+	else
+	    {
 	    struct dnaSeq *extraSeq = hDnaFromSeq(database, chromName, sf->start, sf->end, dnaUpper);
+	    refDna = extraSeq->dna;
+	    }
 	int si = s;
-	char *ptr1 = extraSeq->dna;
+	char *ptr1 = refDna;
 	char *ptr2 = ourDna;
 	for(; si < e; si++,ptr1++,ptr2++)
 	    {
 	    if (*ptr1 != *ptr2)
 		{
 		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)
 	    {
 	    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);
+		refDna, seqLen, TRUE, FALSE);
 	    }
 
     }
     sf->drawn = TRUE;
     tEnd = e;
     tStart = s;
     qStart = sf->qStart;
     lastY = y;
     lastLevel = sf->level;
     //lastX = x;
     }
 
 if (vis != tvFull)
     return;
 
@@ -1059,31 +1069,34 @@
 	    }
 	else
 	    {
 	    lf = hel->val;
 	    }
 
 	struct snakeFeature  *sf;
 	AllocVar(sf);
 	slAddHead(&lf->components, sf);
 	
 	sf->start = cur->tStart;
 	sf->end = cur->tStart + cur->size;
 	sf->qStart = cur->qStart;
 	sf->qEnd = cur->qStart + cur->size;
 	sf->orientation = (cur->strand == '+') ? 1 : -1;
-	sf->sequence = cloneString(cur->sequence);
+	sf->tSequence = cloneString(cur->tSequence);
+	sf->qSequence = cloneString(cur->qSequence);
+	toUpperN(sf->tSequence, strlen(sf->tSequence));
+	toUpperN(sf->qSequence, strlen(sf->qSequence));
 	sf->qName = cur->qChrom;
 
 	cur = cur->next;
     }
     if (tg->visibility == tvFull)
 	{
 	for(lf=lfList; lf ; lf = lf->next)
 	    {
 	    slSort(&lf->components, snakeFeatureCmpQStart);
 	    }
 	}
     else if ((tg->visibility == tvPack) && (lfList != NULL))
 	{
 	assert(lfList->next == NULL);
 	slSort(&lfList->components, snakeFeatureCmpTStart);