3795ab801200f7c44c272602b5ae842cfb420624
angie
  Thu Oct 10 11:58:10 2013 -0700
Found one more place where a resetMergeState was necessary.Without the reset, large-bin items from the previous chrom could
still be hanging out in bigItemQueue when we query the next chrom.

diff --git src/hg/lib/annoStreamDb.c src/hg/lib/annoStreamDb.c
index df19d75..48939de 100644
--- src/hg/lib/annoStreamDb.c
+++ src/hg/lib/annoStreamDb.c
@@ -295,31 +295,34 @@
     if (self->doNextChunk)
 	sqlDyStringPrintf(query, "%s >= %u and ", self->startField, self->nextChunkStart);
     sqlDyStringPrintf(query, "%s < %u and %s > %u ", self->startField, sSelf->regionEnd,
 		      self->endField, start);
     if (self->notSorted)
 	sqlDyStringPrintf(query, "order by %s ", self->startField);
     sqlDyStringPrintf(query, "limit %d", queryMaxItems);
     bufferRowsFromSqlQuery(self, query->string, queryMaxItems);
     }
 else
     {
     // Genome-wide query: break it into chrom-by-chrom queries.
     if (self->queryChrom == NULL)
 	self->queryChrom = self->chromList;
     else if (!self->doNextChunk)
+	{
 	self->queryChrom = self->queryChrom->next;
+	resetMergeState(self);
+	}
     if (minChrom != NULL)
 	{
 	// Skip chroms that precede minChrom
 	while (self->queryChrom != NULL && strcmp(self->queryChrom->name, minChrom) < 0)
 	    {
 	    self->queryChrom = self->queryChrom->next;
 	    self->doNextChunk = FALSE;
 	    resetMergeState(self);
 	    }
 	if (self->hasBin)
 	    {
 	    self->mergeBins = TRUE;
 	    if (self->qLm == NULL)
 		self->qLm = lmInit(0);
 	    }