Imported Upstream version 0.1.5
[tabix.git] / tabix.h
1 /* The MIT License
2
3    Copyright (c) 2009 Genome Research Ltd (GRL), 2010 Broad Institute
4
5    Permission is hereby granted, free of charge, to any person obtaining
6    a copy of this software and associated documentation files (the
7    "Software"), to deal in the Software without restriction, including
8    without limitation the rights to use, copy, modify, merge, publish,
9    distribute, sublicense, and/or sell copies of the Software, and to
10    permit persons to whom the Software is furnished to do so, subject to
11    the following conditions:
12
13    The above copyright notice and this permission notice shall be
14    included in all copies or substantial portions of the Software.
15
16    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20    BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21    ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22    CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23    SOFTWARE.
24 */
25
26 /* Contact: Heng Li <lh3@live.co.uk> */
27
28 #ifndef __TABIDX_H
29 #define __TABIDX_H
30
31 #include <stdint.h>
32 #include "kstring.h"
33 #include "bgzf.h"
34
35 #define TI_PRESET_GENERIC 0
36 #define TI_PRESET_SAM     1
37 #define TI_PRESET_VCF     2
38
39 #define TI_FLAG_UCSC      0x10000
40
41 typedef int (*ti_fetch_f)(int l, const char *s, void *data);
42
43 struct __ti_index_t;
44 typedef struct __ti_index_t ti_index_t;
45
46 typedef struct {
47         int32_t preset;
48         int32_t sc, bc, ec;
49         int32_t meta_char, line_skip;
50 } ti_conf_t;
51
52 extern ti_conf_t ti_conf_gff, ti_conf_bed, ti_conf_psltbl, ti_conf_vcf, ti_conf_sam;
53
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57
58         int ti_readline(BGZF *fp, kstring_t *str);
59
60         int ti_index_build(const char *fn, const ti_conf_t *conf);
61         ti_index_t *ti_index_load(const char *fn);
62     int ti_list_chromosomes(const char *fn);
63         void ti_index_destroy(ti_index_t *idx);
64         int ti_parse_region(ti_index_t *idx, const char *str, int *tid, int *begin, int *end);
65         int ti_fetch(BGZF *fp, const ti_index_t *idx, int tid, int beg, int end, void *data, ti_fetch_f func);
66
67 #ifdef __cplusplus
68 }
69 #endif
70
71 #endif