]> git.donarmstrong.com Git - samtools.git/blobdiff - bamtk.c
Release samtools-0.1.3
[samtools.git] / bamtk.c
diff --git a/bamtk.c b/bamtk.c
index aeb7d0a77ecca4a0faef75eff8c559f87ff06cb3..67dec9ed14f49ff614fd9fe654092a85cb370229 100644 (file)
--- a/bamtk.c
+++ b/bamtk.c
@@ -3,7 +3,7 @@
 #include "bam.h"
 
 #ifndef PACKAGE_VERSION
-#define PACKAGE_VERSION "0.1.2-20"
+#define PACKAGE_VERSION "0.1.3"
 #endif
 
 int bam_taf2baf(int argc, char *argv[]);
@@ -51,6 +51,10 @@ int bam_view(int argc, char *argv[])
        fp = strcmp(argv[optind], "-")? bam_open(argv[optind], "r") : bam_dopen(fileno(stdin), "r");
        assert(fp);
        header = bam_header_read(fp);
+       if (header == 0) {
+               fprintf(stderr, "[bam_view] fail to read the BAM header. Abort!\n");
+               return 1;
+       }
        if (is_bam) {
                assert(fpout = bam_dopen(fileno(stdout), "w"));
                bam_header_write(fpout, header);
@@ -82,7 +86,10 @@ int bam_view(int argc, char *argv[])
                for (i = optind + 1; i < argc; ++i) {
                        int tid, beg, end;
                        bam_parse_region(header, argv[i], &tid, &beg, &end);
-                       if (tid < 0) return 0;
+                       if (tid < 0) {
+                               fprintf(stderr, "[bam_view] fail to get the reference name. Abort!\n");
+                               return 1;
+                       }
                        if (is_bam) bam_fetch(fp, idx, tid, beg, end, fpout, view_auxb);
                        else bam_fetch(fp, idx, tid, beg, end, header, view_aux);
                }