d8be68aa9069713f36e39675355b0ba99b873efb angie Fri Oct 2 12:59:20 2015 -0700 Test & fix VCF+tabix querying of insertion items. diff --git src/lib/annoStreamVcf.c src/lib/annoStreamVcf.c index cdd2a81..149aa08 100644 --- src/lib/annoStreamVcf.c +++ src/lib/annoStreamVcf.c @@ -16,38 +16,41 @@ char *asWords[VCF_NUM_COLS]; // Current row of VCF with genotypes squashed for autoSql struct dyString *dyGt; // Scratch space for squashing genotype columns struct hash *chromNameHash; // Translate "chr"-less seq names if necessary. struct annoRow *indelQ; // FIFO for coord-tweaked indels, to maintain sorting struct annoRow *nextPosQ; // FIFO (max len=1) for stashing row while draining indelQ struct lm *qLm; // Local mem for saving rows in Q's (callerLm disappears) int numFileCols; // Number of columns in VCF file. int maxRecords; // Maximum number of annoRows to return. int recordCount; // Number of annoRows we have returned so far. boolean isTabix; // True if we are accessing compressed VCF via tabix index boolean eof; // True when we have hit end of file or maxRecords }; static void asvSetRegion(struct annoStreamer *vSelf, char *chrom, uint regionStart, uint regionEnd) -/* Set region -- and free current sqlResult if there is one. */ +/* Set region and reset internal state. */ { annoStreamerSetRegion(vSelf, chrom, regionStart, regionEnd); struct annoStreamVcf *self = (struct annoStreamVcf *)vSelf; self->indelQ = self->nextPosQ = NULL; self->eof = FALSE; if (self->isTabix && chrom != NULL) { + // In order to include insertions at the start of region, decrement regionStart. + if (regionStart > 0) + regionStart--; // If this region is not in tabix index, set self->eof so we won't keep grabbing rows // from the old position. boolean gotRegion = lineFileSetTabixRegion(self->vcff->lf, chrom, regionStart, regionEnd); if (! gotRegion) self->eof = TRUE; } } static char *asvGetHeader(struct annoStreamer *vSelf) /* Return VCF header (e.g. for use by formatter) */ { struct annoStreamVcf *self = (struct annoStreamVcf *)vSelf; return cloneString(self->vcff->headerString); }