]> git.donarmstrong.com Git - samtools.git/blobdiff - bedidx.c
* synchronize bgzf in tabix and in samtools
[samtools.git] / bedidx.c
index 9b76af74ac71302521a8c01b0a100d8d8e1e904d..92978318d4ccfbbabeeddd150458245f669062d8 100644 (file)
--- a/bedidx.c
+++ b/bedidx.c
@@ -26,7 +26,7 @@ int *bed_index_core(int n, uint64_t *a, int *n_idx)
        m = *n_idx = 0; idx = 0;
        for (i = 0; i < n; ++i) {
                int beg, end;
-               beg = a[i]>>32; end = (uint32_t)a[i];
+               beg = a[i]>>32 >> LIDX_SHIFT; end = ((uint32_t)a[i]) >> LIDX_SHIFT;
                if (m < end + 1) {
                        int oldm = m;
                        m = end + 1;
@@ -96,8 +96,9 @@ void *bed_read(const char *fn)
        int dret;
        kstring_t *str;
        // read the list
-       str = calloc(1, sizeof(kstring_t));
        fp = strcmp(fn, "-")? gzopen(fn, "r") : gzdopen(fileno(stdin), "r");
+       if (fp == 0) return 0;
+       str = calloc(1, sizeof(kstring_t));
        ks = ks_init(fp);
        while (ks_getuntil(ks, 0, str, &dret) >= 0) { // read the chr name
                int beg = -1, end = -1;