NVBIO
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
tbx.h
Go to the documentation of this file.
1 #ifndef TBX_H
2 #define TBX_H
3 
4 #include "hts.h"
5 
6 #define TBX_MAX_SHIFT 31
7 
8 #define TBX_GENERIC 0
9 #define TBX_SAM 1
10 #define TBX_VCF 2
11 #define TBX_UCSC 0x10000
12 
13 typedef struct {
15  int32_t sc, bc, ec; // seq col., beg col. and end col.
16  int32_t meta_char, line_skip;
17 } tbx_conf_t;
18 
19 typedef struct {
22  void *dict;
23 } tbx_t;
24 
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31  #define tbx_itr_destroy(iter) hts_itr_destroy(iter)
32  #define tbx_itr_queryi(tbx, tid, beg, end) hts_itr_query((tbx)->idx, (tid), (beg), (end), tbx_readrec)
33  #define tbx_itr_querys(tbx, s) hts_itr_querys((tbx)->idx, (s), (hts_name2id_f)(tbx_name2id), (tbx), hts_itr_query, tbx_readrec)
34  #define tbx_itr_next(htsfp, tbx, itr, r) hts_itr_next(hts_get_bgzfp(htsfp), (itr), (r), (tbx))
35  #define tbx_bgzf_itr_next(bgzfp, tbx, itr, r) hts_itr_next((bgzfp), (itr), (r), (tbx))
36 
37  int tbx_name2id(tbx_t *tbx, const char *ss);
38 
39  /* Internal helper function used by tbx_itr_next() */
41  int tbx_readrec(BGZF *fp, void *tbxv, void *sv, int *tid, int *beg, int *end);
42 
43  int tbx_index_build(const char *fn, int min_shift, const tbx_conf_t *conf);
44  tbx_t *tbx_index_load(const char *fn);
45  const char **tbx_seqnames(tbx_t *tbx, int *n); // free the array but not the values
46  void tbx_destroy(tbx_t *tbx);
47 
48 #ifdef __cplusplus
49 }
50 #endif
51 
52 #endif