16d7e876a99f663dd48809bdaf4319ed78cceb71 angie Wed Apr 30 10:15:25 2014 -0700 User reported in MLQ #13153 that bam reads ending just to the leftof the search region were included in hgTables output. BrianL made a nice test case in #13172. Turns out there was a fencepost error in forming a position range string to pass into samtools. fixes #13172, refs #13153 diff --git src/hg/lib/hgBam.c src/hg/lib/hgBam.c index c455b67..2b39834 100644 --- src/hg/lib/hgBam.c +++ src/hg/lib/hgBam.c @@ -179,31 +179,31 @@ slAddHead(&helper->samList, sam); return 0; } struct samAlignment *bamFetchSamAlignment(char *fileOrUrl, char *chrom, int start, int end, struct lm *lm) /* Fetch region as a list of samAlignments - which is more or less an unpacked * bam record. Results is allocated out of lm, since it tends to be large... */ { struct bamToSamHelper helper; helper.lm = lm; helper.chrom = chrom; helper.dy = dyStringNew(0); helper.samList = NULL; char posForBam[256]; -safef(posForBam, sizeof(posForBam), "%s:%d-%d", chrom, start, end); +safef(posForBam, sizeof(posForBam), "%s:%d-%d", chrom, start+1, end); bamFetch(fileOrUrl, posForBam, bamAddOneSamAlignment, &helper, &helper.samFile); dyStringFree(&helper.dy); slReverse(&helper.samList); return helper.samList; } struct samAlignment *bamReadNextSamAlignments(samfile_t *fh, int count, struct lm *lm) /* Read next count alignments in SAM format, allocated in lm. May return less than * count at end of file. */ { /* Set up helper. */ struct bamToSamHelper helper; helper.lm = lm; helper.chrom = NULL; helper.dy = dyStringNew(0);