X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=bam_sort.c;h=38f15d655c253dc1f7e8cd50dd39c178c448f584;hb=7251efa37992752a8cf62ff363da0ad5099937bd;hp=01f7016dd9a35ef27cf4cc232d7529b25d67880b;hpb=205b696ea778f5b7cfe70e5531bfe6583b5af333;p=samtools.git diff --git a/bam_sort.c b/bam_sort.c index 01f7016..38f15d6 100644 --- a/bam_sort.c +++ b/bam_sort.c @@ -222,8 +222,11 @@ int bam_merge_core(int by_qname, const char *out, const char *headers, int n, ch ks_heapmake(heap, n, heap); while (heap->pos != HEAP_EMPTY) { bam1_t *b = heap->b; - if ((flag & MERGE_RG) && bam_aux_get(b, "RG") == 0) + if (flag & MERGE_RG) { + uint8_t *rg = bam_aux_get(b, "RG"); + if (rg) bam_aux_del(b, rg); bam_aux_append(b, "RG", 'Z', RG_len[heap->i] + 1, (uint8_t*)RG[heap->i]); + } bam_write1_core(fpout, &b->core, b->data_len, b->data); if ((j = bam_iter_read(fp[heap->i], iter[heap->i], b)) >= 0) { heap->pos = ((uint64_t)b->core.tid<<32) | (uint32_t)b->core.pos<<1 | bam1_strand(b);