From: Heng Li Date: Thu, 2 Apr 2009 14:14:56 +0000 (+0000) Subject: * samtools-0.1.2-20 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;ds=sidebyside;h=5af1150d241e56b349f7d61fd228c67b475b3c19;p=samtools.git * samtools-0.1.2-20 * check if file is truncated in flagstat --- diff --git a/bam_stat.c b/bam_stat.c index a4522da..b0cd301 100644 --- a/bam_stat.c +++ b/bam_stat.c @@ -33,13 +33,15 @@ bam_flagstat_t *bam_flagstat_core(bamFile fp) bam_flagstat_t *s; bam1_t *b; bam1_core_t *c; + int ret; s = (bam_flagstat_t*)calloc(1, sizeof(bam_flagstat_t)); b = bam_init1(); c = &b->core; - while (bam_read1(fp, b) >= 0) { + while ((ret = bam_read1(fp, b)) >= 0) flagstat_loop(s, c); - } bam_destroy1(b); + if (ret != -1) + fprintf(stderr, "[bam_flagstat_core] Truncated file? Continue anyway.\n"); return s; } int bam_flagstat(int argc, char *argv[]) diff --git a/bamtk.c b/bamtk.c index 792699e..aeb7d0a 100644 --- a/bamtk.c +++ b/bamtk.c @@ -3,7 +3,7 @@ #include "bam.h" #ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "0.1.2-19" +#define PACKAGE_VERSION "0.1.2-20" #endif int bam_taf2baf(int argc, char *argv[]);