Gamgee
You miserable little maggot. I'll stove your head in!
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tbx.h
Go to the documentation of this file.
1 /* tbx.h -- tabix API functions.
2 
3  Copyright (C) 2009, 2012-2014 Genome Research Ltd.
4  Copyright (C) 2010, 2012 Broad Institute.
5 
6  Author: Heng Li <lh3@sanger.ac.uk>
7 
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14 
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17 
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 DEALINGS IN THE SOFTWARE. */
25 
26 #ifndef HTSLIB_TBX_H
27 #define HTSLIB_TBX_H
28 
29 #include "hts.h"
30 
31 #define TBX_MAX_SHIFT 31
32 
33 #define TBX_GENERIC 0
34 #define TBX_SAM 1
35 #define TBX_VCF 2
36 #define TBX_UCSC 0x10000
37 
38 typedef struct {
39  int32_t preset;
40  int32_t sc, bc, ec; // seq col., beg col. and end col.
41  int32_t meta_char, line_skip;
42 } tbx_conf_t;
43 
44 typedef struct {
47  void *dict;
48 } tbx_t;
49 
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56  #define tbx_itr_destroy(iter) hts_itr_destroy(iter)
57  #define tbx_itr_queryi(tbx, tid, beg, end) hts_itr_query((tbx)->idx, (tid), (beg), (end), tbx_readrec)
58  #define tbx_itr_querys(tbx, s) hts_itr_querys((tbx)->idx, (s), (hts_name2id_f)(tbx_name2id), (tbx), hts_itr_query, tbx_readrec)
59  #define tbx_itr_next(htsfp, tbx, itr, r) hts_itr_next(hts_get_bgzfp(htsfp), (itr), (r), (tbx))
60  #define tbx_bgzf_itr_next(bgzfp, tbx, itr, r) hts_itr_next((bgzfp), (itr), (r), (tbx))
61 
62  int tbx_name2id(tbx_t *tbx, const char *ss);
63 
64  /* Internal helper function used by tbx_itr_next() */
66  int tbx_readrec(BGZF *fp, void *tbxv, void *sv, int *tid, int *beg, int *end);
67 
68  int tbx_index_build(const char *fn, int min_shift, const tbx_conf_t *conf);
69  tbx_t *tbx_index_load(const char *fn);
70  const char **tbx_seqnames(tbx_t *tbx, int *n); // free the array but not the values
71  void tbx_destroy(tbx_t *tbx);
72 
73 #ifdef __cplusplus
74 }
75 #endif
76 
77 #endif
int tbx_readrec(BGZF *fp, void *tbxv, void *sv, int *tid, int *beg, int *end)
Definition: tbx.c:154
Definition: hts.h:109
const char ** tbx_seqnames(tbx_t *tbx, int *n)
Definition: tbx.c:296
tbx_t * tbx_index_load(const char *fn)
Definition: tbx.c:268
hts_idx_t * idx
Definition: tbx.h:46
int tbx_index_build(const char *fn, int min_shift, const tbx_conf_t *conf)
Definition: tbx.c:253
int32_t sc
Definition: tbx.h:40
tbx_conf_t tbx_conf_vcf
Definition: tbx.c:41
tbx_conf_t conf
Definition: tbx.h:45
int tbx_name2id(tbx_t *tbx, const char *ss)
Definition: tbx.c:66
BGZF * hts_get_bgzfp(htsFile *fp)
Definition: hts.c:473
Definition: hts.c:640
void tbx_destroy(tbx_t *tbx)
Definition: tbx.c:239
Definition: tbx.h:44
tbx_conf_t tbx_conf_sam
Definition: tbx.c:40
int32_t meta_char
Definition: tbx.h:41
tbx_conf_t tbx_conf_bed
Definition: tbx.c:38
tbx_conf_t tbx_conf_psltbl
Definition: tbx.c:39
void * dict
Definition: tbx.h:47
int32_t preset
Definition: tbx.h:39
Definition: tbx.h:38
Definition: bgzf.h:49
tbx_conf_t tbx_conf_gff
Definition: tbx.c:37