49677da901c0122cf1f5ad1ab158dff73571ca28
angie
  Fri Apr 6 10:02:14 2012 -0700
Bugfix for #6152: when checking range overlap, don't forget to checkthat chroms are the same too since annoGrator's queue can end with the
first item from the next chrom.

diff --git src/lib/annoGrator.c src/lib/annoGrator.c
index 4cad8bf..7a43c74 100644
--- src/lib/annoGrator.c
+++ src/lib/annoGrator.c
@@ -104,31 +104,32 @@
 struct annoRow *annoGratorIntegrate(struct annoGrator *self, struct annoRow *primaryRow,
 				    boolean *retRJFilterFailed)
 /* Given a single row from the primary source, get all overlapping rows from internal
  * source, and produce joined output rows.  If retRJFilterFailed is non-NULL and any
  * overlapping row has a rightJoin filter failure (see annoFilter.h),
  * set retRJFilterFailed and stop. */
 {
 struct annoRow *rowList = NULL;
 agCheckPrimarySorting(self, primaryRow);
 agTrimToStart(self, primaryRow->chrom, primaryRow->start);
 agFetchToEnd(self, primaryRow->chrom, primaryRow->end);
 boolean rjFailHard = (retRJFilterFailed != NULL);
 struct annoRow *qRow;
 for (qRow = self->qHead;  qRow != NULL;  qRow = qRow->next)
     {
-    if (qRow->start < primaryRow->end && qRow->end > primaryRow->start)
+    if (qRow->start < primaryRow->end && qRow->end > primaryRow->start &&
+	sameString(qRow->chrom, primaryRow->chrom))
 	{
 	slAddHead(&rowList, annoRowClone(qRow, self->mySource));
 	if (rjFailHard && qRow->rightJoinFail)
 	    {
 	    *retRJFilterFailed = TRUE;
 	    break;
 	    }
 	}
     }
 slReverse(&rowList);
 return rowList;
 }
 
 void annoGratorClose(struct annoStreamer **pSelf)
 /* Free self (including mySource). */