X-Git-Url: https://git.donarmstrong.com/?p=samtools.git;a=blobdiff_plain;f=bam_lpileup.c;h=d4dd63b99b85dd4c5811758153a56757c908a52c;hp=21b477211e38ea8d0fbac8334150c84b52fcff4b;hb=307c147168f7154e3755712797078c513e0b242a;hpb=6d35460bc21ebb0d46704c75301b41a4ed1643d1 diff --git a/bam_lpileup.c b/bam_lpileup.c index 21b4772..d4dd63b 100644 --- a/bam_lpileup.c +++ b/bam_lpileup.c @@ -1,5 +1,6 @@ #include #include +#include #include "bam.h" #include "ksort.h" @@ -102,7 +103,7 @@ static int tview_func(uint32_t tid, uint32_t pos, int n, const bam_pileup1_t *pl } else tv->cur_level[i] = ++tv->max_level; } else { tv->cur_level[i] = tv->pre_level[l++]; - if (p->qpos == p->b->core.l_qseq - 1) { // then return a free slot + if (p->is_tail) { // then return a free slot tv->tail->level = tv->cur_level[i]; tv->tail->next = mp_alloc(tv->mp); tv->tail = tv->tail->next; @@ -150,6 +151,16 @@ static int tview_func(uint32_t tid, uint32_t pos, int n, const bam_pileup1_t *pl tv->pre_level[l++] = tv->pre_level[i]; } tv->n_pre = l; +/* + fprintf(stderr, "%d\t", pos+1); + for (i = 0; i < n; ++i) { + const bam_pileup1_t *p = pl + i; + if (p->is_head) fprintf(stderr, "^"); + if (p->is_tail) fprintf(stderr, "$"); + fprintf(stderr, "%d,", p->level); + } + fprintf(stderr, "\n"); +*/ return 0; } @@ -185,19 +196,3 @@ int bam_lplbuf_push(const bam1_t *b, bam_lplbuf_t *tv) { return bam_plbuf_push(b, tv->plbuf); } - -int bam_lpileup_file(bamFile fp, int mask, bam_pileup_f func, void *func_data) -{ - bam_lplbuf_t *buf; - int ret; - bam1_t *b; - b = (bam1_t*)calloc(1, sizeof(bam1_t)); - buf = bam_lplbuf_init(func, func_data); - bam_plbuf_set_mask(buf->plbuf, mask); - while ((ret = bam_read1(fp, b)) >= 0) - bam_lplbuf_push(b, buf); - bam_lplbuf_push(0, buf); - bam_lplbuf_destroy(buf); - free(b->data); free(b); - return 0; -}