- if (optind + 1 == argc) {
- b = (bam1_t*)calloc(1, sizeof(bam1_t));
- while ((ret = bam_read1(fp, b)) >= 0) bam_view1(header, b);
- if (ret < -1) fprintf(stderr, "[bam_view] truncated file? Continue anyway. (%d)\n", ret);
- free(b->data); free(b);
- } else {
- int i;
- bam_index_t *idx;
- idx = bam_index_load(argv[optind]);
- for (i = optind + 1; i < argc; ++i) {
- int tid, beg, end;
- bam_parse_region(header, argv[i], &tid, &beg, &end);
- if (tid < 0) {
- fprintf(stderr, "[bam_view] fail to get the reference name. Abort!\n");
- return 1;
- }
- if (is_bam) bam_fetch(fp, idx, tid, beg, end, fpout, view_auxb);
- else bam_fetch(fp, idx, tid, beg, end, header, view_aux);
- }
- bam_index_destroy(idx);
- }
+ if (ret < -1) fprintf(stderr, "[bam_view] truncated file? Continue anyway. (%d)\n", ret);
+ free(b->data); free(b);