annotate ezBAMQC/src/htslib/cram/open_trace_file.h @ 20:9de3bbec2479 draft default tip

Uploaded
author youngkim
date Thu, 31 Mar 2016 10:10:37 -0400
parents dfa3745e5fd8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
1 /*
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
2 Author: James Bonfield
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
3
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
4 Copyright (c) 2000-2001 MEDICAL RESEARCH COUNCIL
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
5 All rights reserved
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
6
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
7 Redistribution and use in source and binary forms, with or without
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
8 modification, are permitted provided that the following conditions are met:
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
9
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
10 . Redistributions of source code must retain the above copyright notice,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
11 this list of conditions and the following disclaimer.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
12
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
13 . Redistributions in binary form must reproduce the above copyright notice,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
14 this list of conditions and the following disclaimer in the documentation
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
15 and/or other materials provided with the distribution.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
16
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
17 . Neither the name of the MEDICAL RESEARCH COUNCIL, THE LABORATORY OF
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
18 MOLECULAR BIOLOGY nor the names of its contributors may be used to endorse or
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
19 promote products derived from this software without specific prior written
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
20 permission.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
21
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
23 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
24 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
25 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
26 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
27 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
28 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
29 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
30 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
31 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
32 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
33
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
34 /*
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
35 Copyright (c) 2008, 2009, 2013 Genome Research Ltd.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
36 Author: James Bonfield <jkb@sanger.ac.uk>
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
37
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
38 Redistribution and use in source and binary forms, with or without
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
39 modification, are permitted provided that the following conditions are met:
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
40
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
41 1. Redistributions of source code must retain the above copyright notice,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
42 this list of conditions and the following disclaimer.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
43
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
44 2. Redistributions in binary form must reproduce the above copyright notice,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
45 this list of conditions and the following disclaimer in the documentation
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
46 and/or other materials provided with the distribution.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
47
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
48 3. Neither the names Genome Research Ltd and Wellcome Trust Sanger
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
49 Institute nor the names of its contributors may be used to endorse or promote
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
50 products derived from this software without specific prior written permission.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
51
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
52 THIS SOFTWARE IS PROVIDED BY GENOME RESEARCH LTD AND CONTRIBUTORS "AS IS" AND
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
53 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
54 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
55 DISCLAIMED. IN NO EVENT SHALL GENOME RESEARCH LTD OR CONTRIBUTORS BE LIABLE
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
56 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
57 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
58 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
59 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
60 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
61 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
62 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
63
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
64 #ifndef _OPEN_TRACE_FILE_H_
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
65 #define _OPEN_TRACE_FILE_H_
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
66
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
67 #include "cram/mFILE.h"
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
68
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
69 #ifdef __cplusplus
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
70 extern "C" {
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
71 #endif
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
72
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
73 /*
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
74 * Tokenises the search path splitting on colons (unix) or semicolons
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
75 * (windows).
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
76 * We also explicitly add a "./" to the end of the search path
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
77 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
78 * Returns: A new search path with items separated by nul chars. Two nul
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
79 * chars in a row represent the end of the tokenised path.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
80 * Returns NULL for a failure.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
81 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
82 * The returned data has been malloced. It is up to the caller to free this
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
83 * memory.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
84 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
85 char *tokenise_search_path(char *searchpath);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
86
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
87 /*
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
88 * Opens a trace file named 'file'. This is initially looked for as a
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
89 * pathname relative to a file named "relative_to". This may (for
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
90 * example) be the name of an experiment file referencing the trace
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
91 * file. In this case by passing relative_to as the experiment file
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
92 * filename the trace file will be picked up in the same directory as
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
93 * the experiment file. Relative_to may be supplied as NULL.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
94 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
95 * 'file' is looked for at relative_to, then the current directory, and then
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
96 * all of the locations listed in 'path' (which is a colon separated list).
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
97 * If 'path' is NULL it uses the RAWDATA environment variable instead.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
98 *
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
99 * Returns a mFILE pointer when found.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
100 * NULL otherwise.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
101 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
102 mFILE *open_path_mfile(char *file, char *path, char *relative_to);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
103
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
104 /*
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
105 * Returns a mFILE containing the entire contents of the url;
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
106 * NULL on failure.
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
107 */
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
108 mFILE *find_file_url(char *file, char *url);
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
109
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
110
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
111 #ifdef __cplusplus
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
112 }
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
113 #endif
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
114
dfa3745e5fd8 Uploaded
youngkim
parents:
diff changeset
115 #endif /* _OPEN_TRACE_FILE_H_ */