2 cdef extern from "string.h":
4 void *memcpy(void *dst,void *src,size_t len)
5 void *memmove(void *dst,void *src,size_t len)
6 void *memset(void *b,int c,size_t len)
7 char *strtok_r(char *str, char *delim, char **saveptr)
8 char *strncpy(char *dest, char *src, size_t n)
9 void *memchr(void *s, int c, size_t n)
11 cdef extern from "stdlib.h":
14 void *calloc(size_t,size_t)
15 void *realloc(void *,size_t)
16 void qsort(void *base, size_t nmemb, size_t size,
17 int (*compar)(void *,void *))
20 long atol( char *nptr)
21 double atof( char *nptr)
23 cdef extern from "stdio.h":
26 FILE *fopen(char *,char *)
27 FILE *freopen(char *path, char *mode, FILE *stream)
28 int fileno(FILE *stream)
29 int dup2(int oldfd, int newfd)
30 int fflush(FILE *stream)
35 int sscanf(char *str,char *fmt,...)
36 int printf(char *str,char *fmt,...)
37 int sprintf(char *str,char *fmt,...)
38 int fprintf(FILE *ifile,char *fmt,...)
39 char *fgets(char *str,int size,FILE *ifile)
41 cdef extern from "ctype.h":
45 cdef extern from "sys/types.h":
48 cdef extern from "sys/stat.h":
51 cdef extern from "fcntl.h":
52 int open(char *pathname, int flags)
54 cdef extern from "unistd.h":
58 ssize_t read(int fd, void *buf, size_t count)
60 cdef extern from "string.h":
61 int strcmp(char *s1, char *s2)
62 int strncmp(char *s1,char *s2,size_t len)
63 char *strcpy(char *dest,char *src)
64 char *strncpy(char *dest,char *src, size_t len)
66 char *strcat(char *,char *)
67 size_t strlen(char *s)
68 int memcmp( void * s1, void *s2, size_t len )
70 cdef extern from "stdint.h":
77 cdef extern from "Python.h":
79 FILE* PyFile_AsFile(object)
80 char *fgets(char *str, int size, FILE *ifile)
81 int feof(FILE *stream)
82 size_t strlen(char *s)
83 size_t getline(char **lineptr, size_t *n, FILE *stream)
84 char *strstr(char *, char *)
85 char *strchr(char *string, int c)
86 int fileno(FILE *stream)
88 cdef extern from "bgzf.h":
93 int64_t bgzf_seek(BGZF* fp, int64_t pos, int where)
95 BGZF * bgzf_open(char * path, char * mode)
97 int bgzf_write(BGZF * fp, void* data, int length)
99 int bgzf_close(BGZF* fp)
102 cdef extern from "tabix.h":
104 ctypedef struct ti_conf_t:
107 int32_t meta_char, line_skip
109 ctypedef struct ti_index_t:
112 ctypedef struct tabix_t:
118 ctypedef struct ti_iter_t:
121 tabix_t *ti_open(char *fn, char *fnidx)
123 int ti_lazy_index_load(tabix_t *t)
125 void ti_close(tabix_t *t)
127 ti_iter_t ti_query(tabix_t *t, char *name, int beg, int end)
128 ti_iter_t ti_queryi(tabix_t *t, int tid, int beg, int end)
129 ti_iter_t ti_querys(tabix_t *t, char *reg)
130 char * ti_read(tabix_t *t, ti_iter_t iter, int *len)
132 # Get the list of sequence names. Each "char*" pointer points to a
133 # internal member of the index, so DO NOT modify the returned
134 # pointer; otherwise the index will be corrupted. The returned
135 # pointer should be freed by a single free() call by the routine
136 # calling this function. The number of sequences is returned at *n
137 char **ti_seqname(ti_index_t *idx, int *n)
139 # Destroy the iterator
140 void ti_iter_destroy(ti_iter_t iter)
142 # Build the index for file <fn>. File <fn>.tbi will be generated
143 # and overwrite the file of the same name. Return -1 on failure. */
144 int ti_index_build(char *fn, ti_conf_t *conf)
146 #/* Load the index from file <fn>.tbi. If <fn> is a URL and the index
147 # * file is not in the working directory, <fn>.tbi will be
148 # * downloaded. Return NULL on failure. */
149 ti_index_t *ti_index_load( char *fn)
151 ti_index_t *ti_index_load_local(char *fnidx)
153 #/* Destroy the index */
154 void ti_index_destroy(ti_index_t *idx)
156 #/* Parse a region like: chr2, chr2:100, chr2:100-200. Return -1 on failure. */
157 int ti_parse_region( ti_index_t *idx, char *str, int *tid, int *begin, int *end)
159 int ti_get_tid( ti_index_t *idx, char *name)
161 # /* Get the iterator pointing to the first record at the current file
162 # * position. If the file is just openned, the iterator points to the
163 # * first record in the file. */
164 ti_iter_t ti_iter_first()
166 # /* Get the iterator pointing to the first record in region tid:beg-end */
167 ti_iter_t ti_iter_query( ti_index_t *idx, int tid, int beg, int end)
169 # /* Get the data line pointed by the iterator and iterate to the next record. */
170 # char *ti_iter_read(BGZF *fp, ti_iter_t iter, int *len)
172 cdef class Tabixfile:
173 cdef char * _filename
175 # pointer to tabixfile
176 cdef tabix_t * tabixfile