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)
8 cdef extern from "stdlib.h":
11 void *calloc(size_t,size_t)
12 void *realloc(void *,size_t)
14 void qsort(void *base, size_t nmemb, size_t size,
15 int (*compar)(void *,void *))
17 cdef extern from "stdio.h":
20 FILE *fopen(char *,char *)
21 FILE *freopen(char *path, char *mode, FILE *stream)
22 int fileno(FILE *stream)
23 int dup2(int oldfd, int newfd)
24 int fflush(FILE *stream)
29 int sscanf(char *str,char *fmt,...)
30 int printf(char *fmt,...)
31 int sprintf(char *str,char *fmt,...)
32 int fprintf(FILE *ifile,char *fmt,...)
33 char *fgets(char *str,int size,FILE *ifile)
35 cdef extern from "ctype.h":
39 cdef extern from "unistd.h":
43 cdef extern from "string.h":
44 int strcmp(char *s1, char *s2)
45 int strncmp(char *s1,char *s2,size_t len)
46 char *strcpy(char *dest,char *src)
47 char *strncpy(char *dest,char *src, size_t len)
49 char *strcat(char *,char *)
50 size_t strlen(char *s)
51 int memcmp( void * s1, void *s2, size_t len )
53 cdef extern from "Python.h":
54 long _Py_HashPointer(void*)
56 cdef extern from "razf.h":
59 cdef extern from "stdint.h":
67 cdef extern from "bam.h":
69 # IF _IOLIB=2, bamFile = BGZF, see bgzf.h
70 # samtools uses KNETFILE, check how this works
72 ctypedef struct tamFile:
75 ctypedef struct bamFile:
78 ctypedef struct bam1_core_t:
91 ctypedef struct bam1_t:
98 ctypedef struct bam_pileup1_t:
107 ctypedef int (*bam_pileup_f)(uint32_t tid, uint32_t pos, int n, bam_pileup1_t *pl, void *data)
109 ctypedef int (*bam_fetch_f)(bam1_t *b, void *data)
111 ctypedef struct bam_header_t:
120 ctypedef struct bam_index_t:
123 ctypedef struct bam_plbuf_t:
126 ctypedef struct bam_iter_t:
130 void bam_destroy1(bam1_t *)
132 bamFile razf_dopen(int data_fd, char *mode)
134 int64_t bam_seek( bamFile fp, uint64_t voffset, int where)
135 int64_t bam_tell( bamFile fp )
137 # void bam_init_header_hash(bam_header_t *header)
139 ###############################################
140 # stand-ins for samtools macros
141 uint32_t * bam1_cigar( bam1_t * b)
142 char * bam1_qname( bam1_t * b)
143 uint8_t * bam1_seq( bam1_t * b)
144 uint8_t * bam1_qual( bam1_t * b)
145 uint8_t * bam1_aux( bam1_t * b)
147 ###############################################
148 # bam iterator interface
149 bam_iter_t bam_iter_query( bam_index_t *idx, int tid, int beg, int end)
151 int bam_iter_read(bamFile fp, bam_iter_t iter, bam1_t *b)
153 void bam_iter_destroy(bam_iter_t iter)
155 ###############################################
157 bam1_t * bam_dup1( bam1_t *src )
159 bam1_t * bam_copy1(bam1_t *bdst, bam1_t *bsrc)
160 bam_index_t *bam_index_load(char *f )
162 void bam_index_destroy(bam_index_t *idx)
164 int bam_parse_region(bam_header_t *header, char *str, int *ref_id, int *begin, int *end)
166 ###############################################
167 bam_plbuf_t *bam_plbuf_init(bam_pileup_f func, void *data)
169 int bam_fetch(bamFile fp, bam_index_t *idx, int tid, int beg, int end, void *data, bam_fetch_f func)
171 int bam_plbuf_push(bam1_t *b, bam_plbuf_t *buf)
173 void bam_plbuf_destroy(bam_plbuf_t *buf)
174 ########################################
175 # pileup iterator interface
176 ctypedef struct bam_plp_t:
179 ctypedef int (*bam_plp_auto_f)(void *data, bam1_t *b)
181 bam_plp_t bam_plp_init( bam_plp_auto_f func, void *data)
182 int bam_plp_push( bam_plp_t iter, bam1_t *b)
183 bam_pileup1_t *bam_plp_next( bam_plp_t iter, int *_tid, int *_pos, int *_n_plp)
184 bam_pileup1_t *bam_plp_auto( bam_plp_t iter, int *_tid, int *_pos, int *_n_plp)
185 void bam_plp_set_mask(bam_plp_t iter, int mask)
186 void bam_plp_reset(bam_plp_t iter)
187 void bam_plp_destroy(bam_plp_t iter)
189 ##################################################
191 int bam_read1(bamFile fp, bam1_t *b)
193 int bam_write1( bamFile fp, bam1_t *b)
195 bam_header_t *bam_header_init()
197 int bam_header_write( bamFile fp, bam_header_t *header)
199 bam_header_t *bam_header_read( bamFile fp )
201 void bam_header_destroy(bam_header_t *header)
203 bam1_t * bam_dup1( bam1_t *src )
205 bam1_t * bam_copy1(bam1_t *bdst, bam1_t *bsrc)
207 uint8_t *bam_aux_get(bam1_t *b, char tag[2])
209 int bam_aux2i(uint8_t *s)
210 float bam_aux2f(uint8_t *s)
211 double bam_aux2d(uint8_t *s)
212 char bam_aux2A( uint8_t *s)
213 char *bam_aux2Z( uint8_t *s)
215 int bam_reg2bin(uint32_t beg, uint32_t end)
217 uint32_t bam_calend(bam1_core_t *c, uint32_t *cigar)
219 cdef extern from "sam.h":
221 ctypedef struct samfile_t_un:
226 ctypedef struct samfile_t:
231 samfile_t *samopen( char *fn, char * mode, void *aux)
233 int sampileup( samfile_t *fp, int mask, bam_pileup_f func, void *data)
235 void samclose(samfile_t *fp)
237 int samread(samfile_t *fp, bam1_t *b)
239 int samwrite(samfile_t *fp, bam1_t *b)
241 cdef extern from "faidx.h":
243 ctypedef struct faidx_t:
246 int fai_build(char *fn)
248 void fai_destroy(faidx_t *fai)
250 faidx_t *fai_load(char *fn)
252 char *fai_fetch(faidx_t *fai, char *reg, int *len)
254 int faidx_fetch_nseq(faidx_t *fai)
256 char *faidx_fetch_seq(faidx_t *fai, char *c_name,
257 int p_beg_i, int p_end_i, int *len)
259 cdef extern from "pysam_util.h":
261 int pysam_pileup_next(bam1_t *b,
263 bam_pileup1_t ** plp,
269 int pysam_dispatch(int argc, char *argv[] )
271 # stand-in functions for samtools macros
272 void pysam_bam_destroy1( bam1_t * b)
274 # add *nbytes* into the variable length data of *src* at *pos*
275 bam1_t * pysam_bam_update( bam1_t * b,
280 # translate char to unsigned char
281 unsigned char pysam_translate_sequence( char s )