5363e544c6e8c14c6ed825038205d26f5ed0ee8c angie Wed Sep 4 16:27:05 2013 -0700 In order to detect the overlap of two 0-length (insertion) items, we needto expand at least one of their ranges to the two surrounding bases. diff --git src/lib/annoGrator.c src/lib/annoGrator.c index c9f5fd6..1282d5e 100644 --- src/lib/annoGrator.c +++ src/lib/annoGrator.c @@ -116,40 +116,48 @@ } struct annoRow *annoGratorIntegrate(struct annoGrator *self, struct annoStreamRows *primaryData, boolean *retRJFilterFailed, struct lm *callerLm) /* 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: * - any overlapping row has a rightJoin filter failure (see annoFilter.h), or * - overlap rule is agoMustOverlap and no rows overlap, or * - overlap rule is agoMustNotOverlap and any overlapping row is found, * then set retRJFilterFailed and stop. */ { struct annoRow *primaryRow = primaryData->rowList; struct annoRow *rowList = NULL; agCheckPrimarySorting(self, primaryRow); -agTrimToStart(self, primaryRow->chrom, primaryRow->start); -agFetchToEnd(self, primaryRow->chrom, primaryRow->start, primaryRow->end); +// In order to catch the intersection of two 0-length elements (i.e. two insertions), +// we have to broaden our search a little: +int pStart = primaryRow->start, pEnd = primaryRow->end; +if (pStart == pEnd) + { + pStart--; + pEnd++; + } +char *pChrom = primaryRow->chrom; +agTrimToStart(self, pChrom, pStart); +agFetchToEnd(self, pChrom, pStart, pEnd); boolean rjFailHard = (retRJFilterFailed != NULL); if (rjFailHard) *retRJFilterFailed = FALSE; struct annoRow *qRow; for (qRow = self->qHead; qRow != NULL; qRow = qRow->next) { - if (qRow->start < primaryRow->end && qRow->end > primaryRow->start && - sameString(qRow->chrom, primaryRow->chrom)) + if (qRow->start < pEnd && qRow->end > pStart && sameString(qRow->chrom, pChrom)) { int numCols = self->mySource->numCols; enum annoRowType rowType = self->mySource->rowType; slAddHead(&rowList, annoRowClone(qRow, rowType, numCols, callerLm)); if (rjFailHard && qRow->rightJoinFail) { *retRJFilterFailed = TRUE; break; } } } slReverse(&rowList); // If no rows overlapped primary, and there is a right-join, !isExclude (i.e. isInclude) filter, // then we need to set retRJFilterFailed because the condition was not met to include // the primary item.