From b188ebcd53973ed3084aff5d5e2ad4a3475dd17e Mon Sep 17 00:00:00 2001 From: Heng Li Date: Sat, 24 Oct 2009 04:45:12 +0000 Subject: [PATCH] * BUGGY VERSION * improved the interface a bit * bug unfixed --- bam.c | 6 ++++-- bam.h | 2 +- bam_import.c | 7 ------- sam.c | 1 - 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/bam.c b/bam.c index 8b51756..2d0f7f4 100644 --- a/bam.c +++ b/bam.c @@ -292,9 +292,11 @@ void bam_view1(const bam_header_t *header, const bam1_t *b) free(s); } -const char *bam_get_library(const bam_header_t *header, const bam1_t *b) +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"); rg = bam_aux_get(b, "RG"); - return (rg == 0)? 0 : sam_tbl_get(header->rg2lib, (const char*)(rg + 1)); + return (rg == 0)? 0 : sam_tbl_get(h->rg2lib, (const char*)(rg + 1)); } diff --git a/bam.h b/bam.h index 4d30dcc..291b303 100644 --- a/bam.h +++ b/bam.h @@ -438,7 +438,7 @@ extern "C" { char *bam_format1_core(const bam_header_t *header, const bam1_t *b, int of); - const char *bam_get_library(const bam_header_t *header, const bam1_t *b); + const char *bam_get_library(bam_header_t *header, const bam1_t *b); /*! @typedef @abstract Structure for one alignment covering the pileup position. diff --git a/bam_import.c b/bam_import.c index 2b4fb7e..34cc776 100644 --- a/bam_import.c +++ b/bam_import.c @@ -171,13 +171,6 @@ static inline void append_text(bam_header_t *header, kstring_t *str) header->text[header->l_text] = 0; } -int sam_header_parse_rg(bam_header_t *h) -{ - if (h->dict == 0) h->dict = sam_header_parse2(h->text); - if (h->rg2lib) h->rg2lib = sam_header2tbl(h->dict, "RG", "ID", "LB"); - return sam_tbl_size(h->rg2lib); -} - int sam_header_parse(bam_header_t *h) { char **tmp; diff --git a/sam.c b/sam.c index 07524c0..f88ad53 100644 --- a/sam.c +++ b/sam.c @@ -62,7 +62,6 @@ samfile_t *samopen(const char *fn, const char *mode, const void *aux) fprintf(stderr, "[samopen] no @SQ lines in the header.\n"); } else fprintf(stderr, "[samopen] SAM header is present: %d sequences.\n", fp->header->n_targets); } - sam_header_parse_rg(fp->header); } else if (mode[0] == 'w') { // write fp->header = bam_header_dup((const bam_header_t*)aux); if (mode[1] == 'b') { // binary -- 2.39.2