49a9e46f48bc7872a655527694e027e51aa46f38 angie Wed Feb 27 12:19:38 2019 -0800 Oops, forgot to check for NULL in a corner case: VCF file has records only in chromosomes preceding the query region chrom. diff --git src/lib/annoStreamVcf.c src/lib/annoStreamVcf.c index 863672f..0c77235 100644 --- src/lib/annoStreamVcf.c +++ src/lib/annoStreamVcf.c @@ -148,31 +148,32 @@ // 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]); + if (words == NULL) + break; 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++;