]> git.donarmstrong.com Git - samtools.git/commitdiff
* BUGGY VERSION
authorHeng Li <lh3@live.co.uk>
Sat, 24 Oct 2009 04:45:12 +0000 (04:45 +0000)
committerHeng Li <lh3@live.co.uk>
Sat, 24 Oct 2009 04:45:12 +0000 (04:45 +0000)
 * improved the interface a bit
 * bug unfixed

bam.c
bam.h
bam_import.c
sam.c

diff --git a/bam.c b/bam.c
index 8b517565026f276d860f91634789ec8fa2f36195..2d0f7f46b054293a1c2734ed1a581db8dcea95ed 100644 (file)
--- 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 4d30dcc2e494a3bf1477751b1176afc682e47282..291b30314f75d3d882b1d5dc9960e7b709a50c02 100644 (file)
--- 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.
index 2b4fb7e03f956e6ea35a2216c5c853c414fa0aa4..34cc776fed8ffb49575df2baebc9ae33bc64c7ad 100644 (file)
@@ -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 07524c0213b30bcae3870f8424da38daef43ac49..f88ad533dd2aba61a6c16b0d5a10d0972e782c04 100644 (file)
--- 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