From 3c65ee9af86aeb40302ce89eaa1d0516af2c4091 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Sun, 12 Apr 2009 19:32:44 +0000 Subject: [PATCH] * samtools-0.1.2-23 * recognize '*' at the QUAL field --- bam.c | 5 ++++- bam_import.c | 10 ++++++++-- bamtk.c | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/bam.c b/bam.c index e470e62..ee145a1 100644 --- 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'); diff --git a/bam_import.c b/bam_import.c index 404da01..7157f2a 100644 --- a/bam_import.c +++ b/bam_import.c @@ -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 a9d852d..62dc2a6 100644 --- 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[]); -- 2.39.2