3cdb290e612b39be6cc8073bb17112c6c1385a13 angie Wed Feb 21 11:28:22 2018 -0800 Yikes, forgetting to update a loop variable caused subsequent chroms' records to be overlooked when restricting to a region. Big VCFs are usually single-chrom, I guess that's why the bug has been under the radar until now. diff --git src/lib/annoStreamVcf.c src/lib/annoStreamVcf.c index d48021e..863672f 100644 --- src/lib/annoStreamVcf.c +++ src/lib/annoStreamVcf.c @@ -136,41 +136,43 @@ regionStart = max(regionStart, minEnd); } } char **words = nextRowRaw(self); if (regionChrom != NULL && words != NULL) { char *rowChrom = getProperChromName(self, words[0]); if (self->isTabix && strcmp(rowChrom, regionChrom) < 0) { uint regionEnd = sSelf->regionEnd; if (minChrom != NULL && sSelf->chrom == NULL) regionEnd = annoAssemblySeqSize(sSelf->assembly, minChrom); // If lineFileSetTabixRegion fails, just keep the current file position // -- hopefully we'll just be skipping to the next row after region{Chrom,Start,End}. lineFileSetTabixRegion(self->vcff->lf, regionChrom, regionStart, regionEnd); + rowChrom = regionChrom; } // Skip to next row if this is on a previous chromosome, or is on regionChrom but // ends before regionStart or ends at regionStart and is not an insertion. struct vcfRecord *rec = self->record; while (words != NULL && (strcmp(rowChrom, regionChrom) < 0 || (sameString(rowChrom, regionChrom) && (rec->chromEnd < regionStart || (rec->chromStart != rec->chromEnd && rec->chromEnd == regionStart))))) { words = nextRowRaw(self); + rowChrom = getProperChromName(self, words[0]); rec = self->record; } } // Tabix doesn't give us any rows past end of region, but if not using tabix, // detect when we're past end of region. It's possible for a non-indel to precede // an insertion that has the same VCF start coord but is actually to its left, // so we can't just quit as soon as we see anything with chromStart == regionEnd. if (words != NULL && !self->isTabix && sSelf->chrom != NULL && self->record->chromStart > sSelf->regionEnd) { words = NULL; self->record = NULL; } if (words != NULL) self->recordCount++;