diff --git a/bam_lpileup.c b/bam_lpileup.c index e20cc92a5..3e7d1df9b 100644 --- a/bam_lpileup.c +++ b/bam_lpileup.c @@ -100,7 +100,7 @@ void bam_lplbuf_reset(bam_lplbuf_t *buf) buf->n_nodes = 0; } -static int tview_func(uint32_t tid, uint32_t pos, int n, const bam_pileup1_t *pl, void *data) +static int tview_func(uint32_t tid, hts_pos_t pos, int n, const bam_pileup1_t *pl, void *data) { bam_lplbuf_t *tv = (bam_lplbuf_t*)data; freenode_t *p; diff --git a/bam_lpileup.h b/bam_lpileup.h index 24acd2b84..97c732455 100644 --- a/bam_lpileup.h +++ b/bam_lpileup.h @@ -33,7 +33,7 @@ typedef struct __bam_lplbuf_t bam_lplbuf_t; #ifndef BAM_PILEUP_F_DEFINED #define BAM_PILEUP_F_DEFINED -typedef int (*bam_pileup_f)(uint32_t tid, uint32_t pos, int n, const bam_pileup1_t *pl, void *data); +typedef int (*bam_pileup_f)(uint32_t tid, hts_pos_t pos, int n, const bam_pileup1_t *pl, void *data); #endif //BAM_PILEUP_F_DEFINED diff --git a/bam_plbuf.c b/bam_plbuf.c index 12ea25037..5541d553f 100644 --- a/bam_plbuf.c +++ b/bam_plbuf.c @@ -58,11 +58,12 @@ void bam_plbuf_destroy(bam_plbuf_t *buf) int bam_plbuf_push(const bam1_t *b, bam_plbuf_t *buf) { - int ret, n_plp, tid, pos; + int ret, n_plp, tid; + hts_pos_t pos; const bam_pileup1_t *plp; ret = bam_plp_push(buf->iter, b); if (ret < 0) return ret; - while ((plp = bam_plp_next(buf->iter, &tid, &pos, &n_plp)) != 0) + while ((plp = bam_plp64_next(buf->iter, &tid, &pos, &n_plp)) != 0) buf->func(tid, pos, n_plp, plp, buf->data); return 0; } diff --git a/bam_plbuf.h b/bam_plbuf.h index 15345510a..acf333818 100644 --- a/bam_plbuf.h +++ b/bam_plbuf.h @@ -29,7 +29,7 @@ DEALINGS IN THE SOFTWARE. */ #ifndef BAM_PILEUP_F_DEFINED #define BAM_PILEUP_F_DEFINED -typedef int (*bam_pileup_f)(uint32_t tid, uint32_t pos, int n, const bam_pileup1_t *pl, void *data); +typedef int (*bam_pileup_f)(uint32_t tid, hts_pos_t pos, int n, const bam_pileup1_t *pl, void *data); #endif //BAM_PILEUP_F_DEFINED typedef struct { diff --git a/bam_tview.c b/bam_tview.c index 426c79b41..9ac6cdda4 100644 --- a/bam_tview.c +++ b/bam_tview.c @@ -166,21 +166,24 @@ void base_tv_destroy(tview_t* tv) } -int tv_pl_func(uint32_t tid, uint32_t pos, int n, const bam_pileup1_t *pl, void *data) +int tv_pl_func(uint32_t tid, hts_pos_t pos, int n, const bam_pileup1_t *pl, void *data) { tview_t *tv = (tview_t*)data; - int i, j, c, rb, attr, max_ins = 0; + hts_pos_t cp; + int i, j, c, rb, attr, max_ins = 0, interval; uint32_t call = 0; kstring_t ks = KS_INITIALIZE; if (pos < tv->left_pos || tv->ccol > tv->mcol) return 0; // out of screen // print reference rb = (tv->ref && pos - tv->left_pos < tv->l_ref)? tv->ref[pos - tv->left_pos] : 'N'; - for (i = tv->last_pos + 1; i < pos; ++i) { - if (i%10 == 0 && tv->mcol - tv->ccol >= 10) tv->my_mvprintw(tv,0, tv->ccol, "%-d", i+1); - c = tv->ref? tv->ref[i - tv->left_pos] : 'N'; + for (cp = tv->last_pos + 1; cp < pos; ++cp) { + interval = cp < 1000000000 ? 10 : 20; + if (cp%interval == 0 && tv->mcol - tv->ccol >= 10) tv->my_mvprintw(tv,0, tv->ccol, "%-"PRIhts_pos, cp+1); + c = tv->ref? tv->ref[cp - tv->left_pos] : 'N'; tv->my_mvaddch(tv,1, tv->ccol++, c); } - if (pos%10 == 0 && tv->mcol - tv->ccol >= 10) tv->my_mvprintw(tv,0, tv->ccol, "%-d", pos+1); + interval = pos < 1000000000 ? 10 : 20; + if (pos%interval == 0 && tv->mcol - tv->ccol >= 10) tv->my_mvprintw(tv,0, tv->ccol, "%-"PRIhts_pos, pos+1); { // call consensus bcf_callret1_t bcr; memset(&bcr, 0, sizeof bcr); @@ -342,7 +345,7 @@ static int tv_push_aln(const bam1_t *b, tview_t *tv) return 0; } -int base_draw_aln(tview_t *tv, int tid, int pos) +int base_draw_aln(tview_t *tv, int tid, hts_pos_t pos) { assert(tv!=NULL); // reset @@ -359,8 +362,8 @@ int base_draw_aln(tview_t *tv, int tid, int pos) const char *ref_name = sam_hdr_tid2name(tv->header, tv->curr_tid); str = (char*)calloc(strlen(ref_name) + 30, 1); assert(str!=NULL); - sprintf(str, "%s:%d-%d", ref_name, tv->left_pos + 1, tv->left_pos + tv->mcol); - tv->ref = fai_fetch(tv->fai, str, &tv->l_ref); + sprintf(str, "%s:%"PRIhts_pos"-%"PRIhts_pos, ref_name, tv->left_pos + 1, tv->left_pos + tv->mcol); + tv->ref = fai_fetch64(tv->fai, str, &tv->l_ref); free(str); if ( !tv->ref ) { @@ -378,8 +381,9 @@ int base_draw_aln(tview_t *tv, int tid, int pos) bam_lplbuf_push(0, tv->lplbuf); while (tv->ccol < tv->mcol) { - int pos = tv->last_pos + 1; - if (pos%10 == 0 && tv->mcol - tv->ccol >= 10) tv->my_mvprintw(tv,0, tv->ccol, "%-d", pos+1); + hts_pos_t pos = tv->last_pos + 1; + int interval = pos < 1000000000 ? 10 : 20; + if (pos%interval == 0 && tv->mcol - tv->ccol >= 10) tv->my_mvprintw(tv,0, tv->ccol, "%-"PRIhts_pos, pos+1); tv->my_mvaddch(tv,1, tv->ccol++, (tv->ref && pos < tv->l_ref)? tv->ref[pos - tv->left_pos] : 'N'); ++tv->last_pos; } @@ -493,8 +497,9 @@ int bam_tview_main(int argc, char *argv[]) if ( position ) { - int tid, beg, end; - char *name_lim = (char *) hts_parse_reg(position, &beg, &end); + int tid; + hts_pos_t beg, end; + char *name_lim = (char *) hts_parse_reg64(position, &beg, &end); if (name_lim) *name_lim = '\0'; else beg = 0; // region parsing failed, but possibly a seq named "foo:a" tid = bam_name2id(tv->header, position); diff --git a/bam_tview.h b/bam_tview.h index be5ba2b08..2ece1479e 100644 --- a/bam_tview.h +++ b/bam_tview.h @@ -49,11 +49,11 @@ typedef struct AbstractTview { bam_lplbuf_t* lplbuf; sam_hdr_t* header; samFile* fp; - int curr_tid, left_pos; faidx_t* fai; bcf_callaux_t* bca; - int ccol, last_pos, row_shift, base_for, color_for, is_dot, l_ref, ins; + hts_pos_t left_pos, last_pos, l_ref; + int curr_tid, ccol, row_shift, base_for, color_for, is_dot, ins; int no_skip, show_name, inverse; char *ref; /* maps @RG ID => SM (sample), in practice only used to determine whether a particular RG is in the list of allowed ones */ @@ -66,7 +66,7 @@ typedef struct AbstractTview { void (*my_attroff)(struct AbstractTview*,int); void (*my_clear)(struct AbstractTview*); int (*my_colorpair)(struct AbstractTview*,int); - int (*my_drawaln)(struct AbstractTview*,int,int); + int (*my_drawaln)(struct AbstractTview*,int,hts_pos_t); int (*my_loop)(struct AbstractTview*); int (*my_underline)(struct AbstractTview*); } tview_t; @@ -89,12 +89,12 @@ char bam_aux_getCQi(bam1_t *b, int i); #define TV_BASE_NUCL 0 #define TV_BASE_COLOR_SPACE 1 -int tv_pl_func(uint32_t tid, uint32_t pos, int n, const bam_pileup1_t *pl, void *data); +int tv_pl_func(uint32_t tid, hts_pos_t pos, int n, const bam_pileup1_t *pl, void *data); // Added fn_idx to arguments as index file int base_tv_init(tview_t*,const char *fn, const char *fn_fa, const char *fn_idx, const char *samples, const htsFormat *fmt); void base_tv_destroy(tview_t*); -int base_draw_aln(tview_t *tv, int tid, int pos); +int base_draw_aln(tview_t *tv, int tid, hts_pos_t pos); typedef struct Tixel { diff --git a/bam_tview_curses.c b/bam_tview_curses.c index d83387d7d..bfe8db09b 100644 --- a/bam_tview_curses.c +++ b/bam_tview_curses.c @@ -136,11 +136,11 @@ static int curses_colorpair(struct AbstractTview* tv,int flag) { return COLOR_PAIR(flag); } -static int curses_drawaln(struct AbstractTview* tv, int tid, int pos) { +static int curses_drawaln(struct AbstractTview* tv, int tid, hts_pos_t pos) { return base_draw_aln(tv, tid, pos); } -static void tv_win_goto(curses_tview_t *tv, int *tid, int *pos) { +static void tv_win_goto(curses_tview_t *tv, int *tid, hts_pos_t *pos) { char str[256], *p; int i, l = 0; tview_t *base=(tview_t*)tv; @@ -153,15 +153,16 @@ static void tv_win_goto(curses_tview_t *tv, int *tid, int *pos) { if (c == KEY_BACKSPACE || c == '\010' || c == '\177') { if(l > 0) --l; } else if (c == KEY_ENTER || c == '\012' || c == '\015') { - int _tid = -1, _beg, _end; + int _tid = -1; + hts_pos_t _beg, _end; if (str[0] == '=') { - _beg = strtol(str+1, &p, 10) - 1; + _beg = strtoll(str+1, &p, 10) - 1; if (_beg > 0) { *pos = _beg; return; } } else { - char *name_lim = (char *) hts_parse_reg(str, &_beg, &_end); + char *name_lim = (char *) hts_parse_reg64(str, &_beg, &_end); if (name_lim) { char name_terminator = *name_lim; *name_lim = '\0'; @@ -234,7 +235,8 @@ static int curses_underline(tview_t* tv) { } static int curses_loop(tview_t* tv) { - int tid, pos; + int tid; + hts_pos_t pos; curses_tview_t *CTV=(curses_tview_t *)tv; tid = tv->curr_tid; pos = tv->left_pos; while (1) { diff --git a/bam_tview_html.c b/bam_tview_html.c index fe400ad5f..9928bfa2a 100644 --- a/bam_tview_html.c +++ b/bam_tview_html.c @@ -131,14 +131,14 @@ static int html_colorpair(struct AbstractTview* tv,int flag) return (1 << (flag)); } -static int html_drawaln(struct AbstractTview* tv, int tid, int pos) +static int html_drawaln(struct AbstractTview* tv, int tid, hts_pos_t pos) { int y,x; html_tview_t* ptr=FROM_TV(tv); html_clear(tv); base_draw_aln(tv, tid, pos); fputs("
",ptr->out); - fprintf(ptr->out,"