2553fb64af15f254ccc3379618e4dec22a16e065
braney
  Thu Oct 10 16:15:56 2013 -0700
upgrade to Glenn's new API which allows me to only request what I need.
diff --git src/hg/hgTracks/snakeTrack.c src/hg/hgTracks/snakeTrack.c
index f634b8c..c9d6f10 100644
--- src/hg/hgTracks/snakeTrack.c
+++ src/hg/hgTracks/snakeTrack.c
@@ -10,30 +10,33 @@
 #include "hgTracks.h"
 #include "chainBlock.h"
 #include "chainLink.h"
 #include "chainDb.h"
 #include "chainCart.h"
 #include "errCatch.h"
 #include "twoBit.h"
 #include "bigWarn.h"
 #include <pthread.h>
 #include "trackHub.h"
 #include "limits.h"
 #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 *qName;			/* chrom name on other species */
     };
 
 static int snakeFeatureCmpTStart(const void *va, const void *vb)
 /* sort by start position on the target sequence */
 {
@@ -461,31 +464,31 @@
 {
 if (tg->networkErrMsg != NULL)
     {
     // we had a parallel load failure
     tg->drawItems = bigDrawWarning;
     tg->totalHeight = bigWarnTotalHeight;
     return bigWarnTotalHeight(tg, vis);
     }
 
 if (vis == tvDense)
     return tg->lineHeight;
 
 if (vis == tvSquish)
     return tg->lineHeight/2;
 
-int height = 5;  // 5 for room for duplication bars
+int height = DUP_LINE_HEIGHT; 
 struct slList *item = tg->items;
 
 item = tg->items;
 
 for (item=tg->items;item; item = item->next)
     {
     height += tg->itemHeight(tg, item);
     }
 return height;
 }
 
 static void snakeDraw(struct track *tg, int seqStart, int seqEnd,
         struct hvGfx *hvg, int xOff, int yOff, int width, 
         MgFont *font, Color color, enum trackVisibility vis)
 /* Draw linked features items. */
@@ -615,54 +618,53 @@
     else
         {
         if(drawNameInverted)
             {
             hvGfxBox(hvg, textX - 1, y, nameWidth+1, tg->heightPer-1, color);
             hvGfxTextRight(hvg, textX, y, nameWidth, tg->heightPer, MG_WHITE, font, name);
             }
         else
             hvGfxTextRight(hvg, textX, y, nameWidth, tg->heightPer, labelColor, font, name);
         }
     }
 
 // let's draw some blue bars for the duplications
 struct hal_target_dupe_list_t* dupeList = lf->dupeList;
 
-//extern void makeChromosomeShades(struct hvGfx *hvg);
-//if (!chromosomeColorsMade)
-    //makeChromosomeShades(hvg);
-
 int count = 0;
+if ((tg->visibility == tvFull) || (tg->visibility == tvPack)) 
+    {
     for(; dupeList ; dupeList = dupeList->next, count++)
 	{
 	struct hal_target_range_t *range = dupeList->tRange;
 
 	unsigned int colorInt = snakePalette[count % (sizeof(snakePalette)/sizeof(Color))];
 	Color color = MAKECOLOR_32(((colorInt >> 16) & 0xff),((colorInt >> 8) & 0xff),((colorInt >> 0) & 0xff));
 
 	for(; range; range = range->next)
 	    {
 	    int s = range->tStart;
 	    int e = range->tStart + range->size;
 	    int sClp = (s < winStart) ? winStart : s;
 	    int eClp = (e > winEnd) ? winEnd : e;
 	    int x1 = round((sClp - winStart)*scale) + xOff;
 	    int x2 = round((eClp - winStart)*scale) + xOff;
-	hvGfxBox(hvg, x1, y , x2-x1, 3 , color);
+	    hvGfxBox(hvg, x1, y , x2-x1, DUP_LINE_HEIGHT - 1 , color);
+	    }
 	}
+    y+=DUP_LINE_HEIGHT;
     }
-y+=4;
 
 // now we're going to draw the boxes
 
 s = sf->start;
 int lastE = -1;
 int lastS = -1;
 int offY = y;
 int lineHeight = tg->lineHeight ;
 int tStart, tEnd, qStart;
 int  qs, qe;
 int heightPer = tg->heightPer;
 int lastX = -1,lastY = y;
 int lastQEnd = 0;
 int lastLevel = -1;
 int e;
@@ -960,32 +962,37 @@
 void halSnakeLoadItems(struct track *tg)
 // load up a snake from a HAL file.   This code is called in threads
 // so *no* use of globals please. All but full snakes are read into a single
 // linked feature.
 {
 unsigned showSnpWidth = cartOrTdbInt(cart, tg->tdb, 
     SNAKE_SHOW_SNP_WIDTH, SNAKE_DEFAULT_SHOW_SNP_WIDTH);
 
 // if we have a network error we want to put out a message about it
 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 < showSnpWidth) ? 1 : 0;
-    struct hal_block_results_t *head = halGetBlocksInTargetRange(handle, otherSpecies, trackHubSkipHubName(database), chromName, winStart, winEnd, 0, needSeq, 1,0);
+    boolean isPackOrFull = (tg->visibility == tvFull) || 
+	(tg->visibility == tvPack);
+    hal_dup_type_t dupMode =  (isPackOrFull) ? HAL_QUERY_AND_TARGET_DUPS :
+	HAL_QUERY_DUPS;
+    int needSeq = isPackOrFull && (winBaseCount < showSnpWidth) ? 1 : 0;
+    int mapBackAdjacencies = (tg->visibility == tvFull);
+    struct hal_block_results_t *head = halGetBlocksInTargetRange(handle, otherSpecies, trackHubSkipHubName(database), chromName, winStart, winEnd, 0, needSeq, dupMode,mapBackAdjacencies);
 
     // did we get any blocks from HAL
     if (head == NULL)
 	{
 	errCatchEnd(errCatch);
 	return;
 	}
     struct hal_block_t* cur = head->mappedBlocks;
     struct linkedFeatures *lf = NULL;
     struct hash *qChromHash = newHash(5);
     struct linkedFeatures *lfList = NULL;
     char buffer[4096];
 
 #ifdef NOTNOW
     struct hal_target_dupe_list_t* targetDupeBlocks = head->targetDupeBlocks;