Debian Codegraph @

debian/missing-sources/htslib/tbx.h

raw symbols SCIP
1 /// @file htslib/tbx.h
2 /// Tabix API functions.
3 /*
4 Copyright (C) 2009, 2012-2015, 2019 Genome Research Ltd.
5 Copyright (C) 2010, 2012 Broad Institute.
6
7 Author: Heng Li <[email protected]>
8
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 DEALINGS IN THE SOFTWARE. */
26
27 #ifndef HTSLIB_TBX_H
28 #define HTSLIB_TBX_H
29
30 #include "hts.h"
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 #define TBX_MAX_SHIFT 31
37
38 #define TBX_GENERIC 0
39 #define TBX_SAM 1
40 #define TBX_VCF 2
41 #define TBX_UCSC 0x10000
42
43 typedef struct {
44 int32_t preset;
45 int32_t sc, bc, ec; // seq col., beg col. and end col.
46 int32_t meta_char, line_skip;
47 } tbx_conf_t;
48
49 typedef struct {
50 tbx_conf_t conf;
51 hts_idx_t *idx;
52 void *dict;
53 } tbx_t;
54
55 extern const tbx_conf_t tbx_conf_gff, tbx_conf_bed, tbx_conf_psltbl, tbx_conf_sam, tbx_conf_vcf;
56
57 #define tbx_itr_destroy(iter) hts_itr_destroy(iter)
58 #define tbx_itr_queryi(tbx, tid, beg, end) hts_itr_query((tbx)->idx, (tid), (beg), (end), tbx_readrec)
59 #define tbx_itr_querys(tbx, s) hts_itr_querys((tbx)->idx, (s), (hts_name2id_f)(tbx_name2id), (tbx), hts_itr_query, tbx_readrec)
60 #define tbx_itr_next(htsfp, tbx, itr, r) hts_itr_next(hts_get_bgzfp(htsfp), (itr), (r), (tbx))
61 #define tbx_bgzf_itr_next(bgzfp, tbx, itr, r) hts_itr_next((bgzfp), (itr), (r), (tbx))
62
63 HTSLIB_EXPORT
64 int tbx_name2id(tbx_t *tbx, const char *ss);
65
66 /* Internal helper function used by tbx_itr_next() */
67 HTSLIB_EXPORT
68 BGZF *hts_get_bgzfp(htsFile *fp);
69
70 HTSLIB_EXPORT
71 int tbx_readrec(BGZF *fp, void *tbxv, void *sv, int *tid, hts_pos_t *beg, hts_pos_t *end);
72
73 /// Build an index of the lines in a BGZF-compressed file
74 /** The index struct returned by a successful call should be freed
75 via tbx_destroy() when it is no longer needed.
76 */
77 HTSLIB_EXPORT
78 tbx_t *tbx_index(BGZF *fp, int min_shift, const tbx_conf_t *conf);
79 /*
80 * All tbx_index_build* methods return: 0 (success), -1 (general failure) or -2 (compression not BGZF)
81 */
82 HTSLIB_EXPORT
83 int tbx_index_build(const char *fn, int min_shift, const tbx_conf_t *conf);
84
85 HTSLIB_EXPORT
86 int tbx_index_build2(const char *fn, const char *fnidx, int min_shift, const tbx_conf_t *conf);
87
88 HTSLIB_EXPORT
89 int tbx_index_build3(const char *fn, const char *fnidx, int min_shift, int n_threads, const tbx_conf_t *conf);
90
91
92 /// Load or stream a .tbi or .csi index
93 /** @param fn Name of the data file corresponding to the index
94
95 Equivalent to tbx_index_load3(fn, NULL, HTS_IDX_SAVE_REMOTE);
96 */
97 HTSLIB_EXPORT
98 tbx_t *tbx_index_load(const char *fn);
99
100 /// Load or stream a .tbi or .csi index
101 /** @param fn Name of the data file corresponding to the index
102 @param fnidx Name of the indexed file
103 @return The index, or NULL if an error occurred
104
105 If @p fnidx is NULL, the index name will be derived from @p fn.
106
107 Equivalent to tbx_index_load3(fn, fnidx, HTS_IDX_SAVE_REMOTE);
108 */
109 HTSLIB_EXPORT
110 tbx_t *tbx_index_load2(const char *fn, const char *fnidx);
111
112 /// Load or stream a .tbi or .csi index
113 /** @param fn Name of the data file corresponding to the index
114 @param fnidx Name of the indexed file
115 @param flags Flags to alter behaviour (see description)
116 @return The index, or NULL if an error occurred
117
118 If @p fnidx is NULL, the index name will be derived from @p fn.
119
120 The @p flags parameter can be set to a combination of the following
121 values:
122
123 HTS_IDX_SAVE_REMOTE Save a local copy of any remote indexes
124 HTS_IDX_SILENT_FAIL Fail silently if the index is not present
125
126 The index struct returned by a successful call should be freed
127 via tbx_destroy() when it is no longer needed.
128 */
129 HTSLIB_EXPORT
130 tbx_t *tbx_index_load3(const char *fn, const char *fnidx, int flags);
131
132 HTSLIB_EXPORT
133 const char **tbx_seqnames(tbx_t *tbx, int *n); // free the array but not the values
134
135 HTSLIB_EXPORT
136 void tbx_destroy(tbx_t *tbx);
137
138 #ifdef __cplusplus
139 }
140 #endif
141
142 #endif