From 8f9081fe5d62916987b928753d13e06c08322236 Mon Sep 17 00:00:00 2001 From: Petr Danecek Date: Thu, 29 Mar 2012 10:50:16 +0100 Subject: [PATCH] Compile cleanly from top-level Makefile. Check for out of bounds tids. --- misc/Makefile | 3 +++ misc/bamcheck.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/misc/Makefile b/misc/Makefile index 9434399..64aa9df 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -30,6 +30,9 @@ lib: bamcheck:bamcheck.o $(CC) $(CFLAGS) -o $@ bamcheck.o -lm -lz -L.. -lbam +bamcheck.o:bamcheck.c ../faidx.h ../khash.h ../sam.h ../razf.h + $(CC) $(CFLAGS) -c -I.. -o $@ bamcheck.c + ace2sam:ace2sam.o $(CC) $(CFLAGS) -o $@ ace2sam.o -lz diff --git a/misc/bamcheck.c b/misc/bamcheck.c index 7b5fd02..03cf3b2 100644 --- a/misc/bamcheck.c +++ b/misc/bamcheck.c @@ -12,7 +12,7 @@ considered, even small overlap is good enough to include the read in the stats. */ -#define BAMCHECK_VERSION "2012-03-22" +#define BAMCHECK_VERSION "2012-03-29" #define _ISOC99_SOURCE #define _GNU_SOURCE @@ -1240,7 +1240,7 @@ int main(int argc, char *argv[]) { if ( stats->regions ) { - if ( bam_line->core.tid >= stats->nregions ) continue; + if ( bam_line->core.tid >= stats->nregions || bam_line->core.tid<0 ) continue; if ( !stats->is_sorted ) error("The BAM must be sorted in order for -t to work.\n"); regions_t *reg = &stats->regions[bam_line->core.tid]; -- 2.39.2