annotate pyPRADA_1.2/tools/bwa-0.5.7-mh/utils.c @ 0:acc2ca1a3ba4

Uploaded
author siyuan
date Thu, 20 Feb 2014 00:44:58 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
1 /* The MIT License
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
2
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
3 Copyright (c) 2008 Genome Research Ltd (GRL).
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
4
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
5 Permission is hereby granted, free of charge, to any person obtaining
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
6 a copy of this software and associated documentation files (the
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
7 "Software"), to deal in the Software without restriction, including
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
8 without limitation the rights to use, copy, modify, merge, publish,
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
9 distribute, sublicense, and/or sell copies of the Software, and to
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
10 permit persons to whom the Software is furnished to do so, subject to
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
11 the following conditions:
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
12
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
13 The above copyright notice and this permission notice shall be
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
14 included in all copies or substantial portions of the Software.
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
15
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
17 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
18 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
19 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
20 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
21 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
22 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
23 SOFTWARE.
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
24 */
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
25
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
26 /* Contact: Heng Li <lh3@sanger.ac.uk> */
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
27
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
28 #include <stdio.h>
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
29 #include <stdarg.h>
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
30 #include <stdlib.h>
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
31 #include <string.h>
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
32 #include <zlib.h>
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
33 #include "utils.h"
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
34
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
35 FILE *err_xopen_core(const char *func, const char *fn, const char *mode)
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
36 {
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
37 FILE *fp = 0;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
38 if (strcmp(fn, "-") == 0)
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
39 return (strstr(mode, "r"))? stdin : stdout;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
40 if ((fp = fopen(fn, mode)) == 0) {
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
41 fprintf(stderr, "[%s] fail to open file '%s'. Abort!\n", func, fn);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
42 abort();
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
43 }
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
44 return fp;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
45 }
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
46 gzFile err_xzopen_core(const char *func, const char *fn, const char *mode)
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
47 {
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
48 gzFile fp;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
49 if (strcmp(fn, "-") == 0)
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
50 return gzdopen(fileno((strstr(mode, "r"))? stdin : stdout), mode);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
51 if ((fp = gzopen(fn, mode)) == 0) {
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
52 fprintf(stderr, "[%s] fail to open file '%s'. Abort!\n", func, fn);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
53 abort();
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
54 }
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
55 return fp;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
56 }
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
57 void err_fatal(const char *header, const char *fmt, ...)
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
58 {
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
59 va_list args;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
60 va_start(args, fmt);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
61 fprintf(stderr, "[%s] ", header);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
62 vfprintf(stderr, fmt, args);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
63 fprintf(stderr, " Abort!\n");
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
64 va_end(args);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
65 abort();
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
66 }
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
67
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
68 void err_fatal_simple_core(const char *func, const char *msg)
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
69 {
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
70 fprintf(stderr, "[%s] %s Abort!\n", func, msg);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
71 abort();
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
72 }