]> git.donarmstrong.com Git - samtools.git/blobdiff - bam.c
Fixed a bug in knet_seek
[samtools.git] / bam.c
diff --git a/bam.c b/bam.c
index 2d0f7f46b054293a1c2734ed1a581db8dcea95ed..56c95db4e2c42c404627e41bd1ca2360a496af73 100644 (file)
--- a/bam.c
+++ b/bam.c
@@ -268,7 +268,7 @@ char *bam_format1_core(const bam_header_t *header, const bam1_t *b, int of)
                ksprintf(&str, "\t%c%c:", key[0], key[1]);
                if (type == 'A') { ksprintf(&str, "A:%c", *s); ++s; }
                else if (type == 'C') { ksprintf(&str, "i:%u", *s); ++s; }
-               else if (type == 'c') { ksprintf(&str, "i:%d", *s); ++s; }
+               else if (type == 'c') { ksprintf(&str, "i:%d", *(int8_t*)s); ++s; }
                else if (type == 'S') { ksprintf(&str, "i:%u", *(uint16_t*)s); s += 2; }
                else if (type == 's') { ksprintf(&str, "i:%d", *(int16_t*)s); s += 2; }
                else if (type == 'I') { ksprintf(&str, "i:%u", *(uint32_t*)s); s += 4; }
@@ -292,11 +292,12 @@ void bam_view1(const bam_header_t *header, const bam1_t *b)
        free(s);
 }
 
+// FIXME: we should also check the LB tag associated with each alignment
 const char *bam_get_library(bam_header_t *h, const bam1_t *b)
 {
        const uint8_t *rg;
        if (h->dict == 0) h->dict = sam_header_parse2(h->text);
-       if (h->rg2lib) h->rg2lib = sam_header2tbl(h->dict, "RG", "ID", "LB");
+       if (h->rg2lib == 0) h->rg2lib = sam_header2tbl(h->dict, "RG", "ID", "LB");
        rg = bam_aux_get(b, "RG");
        return (rg == 0)? 0 : sam_tbl_get(h->rg2lib, (const char*)(rg + 1));
 }