]> git.donarmstrong.com Git - samtools.git/blobdiff - bam.c
* samtools-0.1.2-24
[samtools.git] / bam.c
diff --git a/bam.c b/bam.c
index 6ccca7c0a1153c336a8e914742f5519abacb6edd..1b74c6d150a8d1003c3775785e7c93e108009b29 100644 (file)
--- a/bam.c
+++ b/bam.c
@@ -102,7 +102,6 @@ bam_header_t *bam_header_read(bamFile fp)
        bam_read(fp, header->text, header->l_text);
        bam_read(fp, &header->n_targets, 4);
        if (bam_is_be) bam_swap_endian_4p(&header->n_targets);
-       assert(header->n_targets > 0);
        // read reference sequence names and lengths
        header->target_name = (char**)calloc(header->n_targets, sizeof(char*));
        header->target_len = (uint32_t*)calloc(header->n_targets, 4);
@@ -166,6 +165,7 @@ static void swap_endian_data(const bam1_core_t *c, int data_len, uint8_t *data)
                if (type == 'C' || type == 'A') ++s;
                else if (type == 'S') { bam_swap_endian_2p(s); s += 2; }
                else if (type == 'I' || type == 'F') { bam_swap_endian_4p(s); s += 4; }
+               else if (type == 'D') { bam_swap_endian_8p(s); s += 8; }
                else if (type == 'Z' || type == 'H') { while (*s) ++s; ++s; }
        }
 }
@@ -249,11 +249,13 @@ void bam_view1(const bam_header_t *header, const bam1_t *b)
        }
        putchar('\t');
        if (c->mtid < 0) printf("*\t");
+       else if (c->mtid == c->tid) printf("=\t");
        else printf("%s\t", header->target_name[c->mtid]);
        printf("%d\t%d\t", c->mpos + 1, c->isize);
        for (i = 0; i < c->l_qseq; ++i) putchar(bam_nt16_rev_table[bam1_seqi(s, i)]);
        putchar('\t');
-       for (i = 0; i < c->l_qseq; ++i) putchar(t[i] + 33);
+       if (t[0] == 0xff) putchar('*');
+       else for (i = 0; i < c->l_qseq; ++i) putchar(t[i] + 33);
        s = bam1_aux(b);
        while (s < b->data + b->data_len) {
                uint8_t type, key[2];
@@ -268,6 +270,7 @@ void bam_view1(const bam_header_t *header, const bam1_t *b)
                else if (type == 'I') { printf("i:%u", *(uint32_t*)s); s += 4; }
                else if (type == 'i') { printf("i:%d", *(int32_t*)s); s += 4; }
                else if (type == 'f') { printf("f:%g", *(float*)s); s += 4; }
+               else if (type == 'd') { printf("d:%lg", *(double*)s); s += 8; }
                else if (type == 'Z' || type == 'H') { printf("%c:", type); while (*s) putchar(*s++); ++s; }
        }
        putchar('\n');