X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=sam_view.c;h=402e280606f7551dfdcc1667dcb289dc78c41a4e;hb=d07731e7c769ac5f2709ac60eb60ddd3fa0120fd;hp=ce1e1092b791386d27d8e88f61dee1ed8332dc3f;hpb=8cf329904235d82c6c781113c404f298d06bc2b0;p=samtools.git diff --git a/sam_view.c b/sam_view.c index ce1e109..402e280 100644 --- a/sam_view.c +++ b/sam_view.c @@ -119,14 +119,14 @@ static int usage(int is_long_help); int main_samview(int argc, char *argv[]) { int c, is_header = 0, is_header_only = 0, is_bamin = 1, ret = 0, compress_level = -1, is_bamout = 0, is_count = 0; - int of_type = BAM_OFDEC, is_long_help = 0; + int of_type = BAM_OFDEC, is_long_help = 0, n_threads = 0; int count = 0; samfile_t *in = 0, *out = 0; char in_mode[5], out_mode[5], *fn_out = 0, *fn_list = 0, *fn_ref = 0, *fn_rg = 0, *q; /* parse command-line options */ strcpy(in_mode, "r"); strcpy(out_mode, "w"); - while ((c = getopt(argc, argv, "SbBct:h1Ho:q:f:F:ul:r:xX?T:R:L:s:Q:")) >= 0) { + while ((c = getopt(argc, argv, "SbBct:h1Ho:q:f:F:ul:r:xX?T:R:L:s:Q:@:")) >= 0) { switch (c) { case 's': if ((g_subsam_seed = strtol(optarg, &q, 10)) != 0) { @@ -157,6 +157,7 @@ int main_samview(int argc, char *argv[]) case 'T': fn_ref = strdup(optarg); is_bamin = 0; break; case 'B': bam_no_B = 1; break; case 'Q': g_qual_scale = atoi(optarg); break; + case '@': n_threads = strtol(optarg, 0, 0); break; default: return usage(is_long_help); } } @@ -214,6 +215,7 @@ int main_samview(int argc, char *argv[]) ret = 1; goto view_end; } + if (n_threads > 1) samthreads(out, n_threads, 256); if (is_header_only) goto view_end; // no need to print alignments if (argc == optind + 1) { // convert/print the entire file @@ -294,6 +296,7 @@ static int usage(int is_long_help) fprintf(stderr, " -X output FLAG in string (samtools-C specific)\n"); fprintf(stderr, " -c print only the count of matching records\n"); fprintf(stderr, " -B collapse the backward CIGAR operation\n"); + fprintf(stderr, " -@ INT number of BAM compression threads [0]\n"); fprintf(stderr, " -L FILE output alignments overlapping the input BED FILE [null]\n"); fprintf(stderr, " -t FILE list of reference names and lengths (force -S) [null]\n"); fprintf(stderr, " -T FILE reference sequence file (force -S) [null]\n"); @@ -364,12 +367,14 @@ int main_bam2fq(int argc, char *argv[]) bam_header_t *h; bam1_t *b; int8_t *buf; - int max_buf; + int max_buf, c, no12 = 0; + while ((c = getopt(argc, argv, "n")) > 0) + if (c == 'n') no12 = 1; if (argc == 1) { fprintf(stderr, "Usage: samtools bam2fq \n"); return 1; } - fp = strcmp(argv[1], "-")? bam_open(argv[1], "r") : bam_dopen(fileno(stdin), "r"); + fp = strcmp(argv[optind], "-")? bam_open(argv[optind], "r") : bam_dopen(fileno(stdin), "r"); if (fp == 0) return 1; h = bam_header_read(fp); b = bam_init1(); @@ -379,9 +384,12 @@ int main_bam2fq(int argc, char *argv[]) int i, qlen = b->core.l_qseq; uint8_t *seq; putchar('@'); fputs(bam1_qname(b), stdout); - if ((b->core.flag & 0x40) && !(b->core.flag & 0x80)) puts("/1"); - else if ((b->core.flag & 0x80) && !(b->core.flag & 0x40)) puts("/2"); - else putchar('\n'); + if (no12) putchar('\n'); + else { + if ((b->core.flag & 0x40) && !(b->core.flag & 0x80)) puts("/1"); + else if ((b->core.flag & 0x80) && !(b->core.flag & 0x40)) puts("/2"); + else putchar('\n'); + } if (max_buf < qlen + 1) { max_buf = qlen + 1; kroundup32(max_buf);