limit fstBC to 30bp in Python3 ver.
[GalaxyCodeBases.git] / c_cpp / lib / htslib / test / thrash_threads5.c
blob1fe1cd29f6ffe2d0562a5395e86de5f397b27c99
1 /* The MIT/Expat License
3 Copyright (C) 2017 Genome Research Ltd.
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 DEALINGS IN THE SOFTWARE.
23 // A basic 'zcat filename [N-threads]'
25 #include <config.h>
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <unistd.h>
30 #include "htslib/bgzf.h"
31 #include "htslib/thread_pool.h"
33 #define N 1000
34 int main(int argc, char *argv[]) {
35 char buf[N];
36 ssize_t l, t = 0;
38 if (argc < 2 || isatty(STDOUT_FILENO)) {
39 fprintf(stderr,
40 "Usage: thrash_threads5 input.bam num_threads | md5sum\n");
41 exit(1);
44 BGZF *fpin = bgzf_open(argv[1], "r");
45 hts_tpool *p = NULL;
46 if (argc > 2) {
47 p = hts_tpool_init(atoi(argv[2]));
48 bgzf_thread_pool(fpin, p, 0);
50 int n = rand()%(N-1)+1;
51 while ((l = bgzf_read(fpin, buf, n)) > 0) {
52 if (l != write(STDOUT_FILENO, buf, l)) abort();
53 t += l;
54 if (l != n) {
55 fprintf(stderr, "expected %d bytes, got %d\n", n, (int)l);
56 break;
58 n = rand()%(N-1)+1;
60 fprintf(stderr, "close=%d\n", (int)bgzf_close(fpin));
61 if (p) hts_tpool_destroy(p);
63 fprintf(stderr, "wrote %d bytes\n", (int)t);
65 return 0;