]> git.donarmstrong.com Git - samtools.git/commitdiff
* samtools-0.1.2-23
authorHeng Li <lh3@live.co.uk>
Sun, 12 Apr 2009 19:32:44 +0000 (19:32 +0000)
committerHeng Li <lh3@live.co.uk>
Sun, 12 Apr 2009 19:32:44 +0000 (19:32 +0000)
 * recognize '*' at the QUAL field

bam.c
bam_import.c
bamtk.c

diff --git a/bam.c b/bam.c
index e470e629430cc23e0d9426dcdd1b3db764f6a1d0..ee145a1f20587236e8b4b99567f9d9f23eb3ba02 100644 (file)
--- a/bam.c
+++ b/bam.c
@@ -166,6 +166,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; }
        }
 }
@@ -254,7 +255,8 @@ void bam_view1(const bam_header_t *header, const bam1_t *b)
        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];
@@ -269,6 +271,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');
index 404da01eb82841c48dd62fb03ec9d7bedff51865..7157f2ae242aef58c621702b07448cefc83e34a8 100644 (file)
@@ -227,10 +227,11 @@ int sam_read1(tamFile fp, bam_header_t *header, bam1_t *b)
                for (i = 0; i < c->l_qseq; ++i)
                        p[i/2] |= bam_nt16_table[(int)str->s[i]] << 4*(1-i%2);
                if (ks_getuntil(ks, KS_SEP_TAB, str, &dret) < 0) return -6; // qual
-               if (c->l_qseq != strlen(str->s))
+               if (strcmp(str->s, "*") && c->l_qseq != strlen(str->s))
                        parse_error(fp->n_lines, "sequence and quality are inconsistent");
                p += (c->l_qseq+1)/2;
-               for (i = 0; i < c->l_qseq; ++i) p[i] = str->s[i] - 33;
+               if (strcmp(str->s, "*") == 0) for (i = 0; i < c->l_qseq; ++i) p[i] = 0xff;
+               else for (i = 0; i < c->l_qseq; ++i) p[i] = str->s[i] - 33;
                doff += c->l_qseq + (c->l_qseq+1)/2;
        }
        doff0 = doff;
@@ -285,6 +286,11 @@ int sam_read1(tamFile fp, bam_header_t *header, bam1_t *b)
                                *s++ = 'f';
                                *(float*)s = (float)atof(str->s + 5);
                                s += 4; doff += 5;
+                       } else if (type == 'd') {
+                               s = alloc_data(b, doff + 9) + doff;
+                               *s++ = 'd';
+                               *(float*)s = (float)atof(str->s + 9);
+                               s += 8; doff += 9;
                        } else if (type == 'Z' || type == 'H') {
                                int size = 1 + (str->l - 5) + 1;
                                if (type == 'H') { // check whether the hex string is valid
diff --git a/bamtk.c b/bamtk.c
index a9d852d49060732f9f543e936c267ab3f9f3fe5d..62dc2a6ebfce1d14554b6d54c8e7d078dc1ecf5b 100644 (file)
--- a/bamtk.c
+++ b/bamtk.c
@@ -3,7 +3,7 @@
 #include "bam.h"
 
 #ifndef PACKAGE_VERSION
-#define PACKAGE_VERSION "0.1.2-22"
+#define PACKAGE_VERSION "0.1.2-23"
 #endif
 
 int bam_taf2baf(int argc, char *argv[]);