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 *str,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 "razf.h":
56 cdef extern from "stdint.h":
64 cdef extern from "bam.h":
66 # IF _IOLIB=2, bamFile = BGZF, see bgzf.h
67 # samtools uses KNETFILE, check how this works
69 ctypedef struct tamFile:
72 ctypedef struct bamFile:
75 ctypedef struct bam1_core_t:
88 ctypedef struct bam1_t:
95 ctypedef struct bam_pileup1_t:
104 ctypedef int (*bam_pileup_f)(uint32_t tid, uint32_t pos, int n, bam_pileup1_t *pl, void *data)
106 ctypedef int (*bam_fetch_f)(bam1_t *b, void *data)
108 ctypedef struct bam_header_t:
117 ctypedef struct bam_index_t:
120 ctypedef struct bam_plbuf_t:
123 bamFile razf_dopen(int data_fd, char *mode)
125 # removed - macros not found
127 # int64_t bam_seek( bamFile fp, uint64_t voffset, int where)
128 # int64_t bam_tell( bamFile fp )
129 # void bam_destroy1( bam1_t * b)
130 # void bam_init_header_hash(bam_header_t *header)
132 bam1_t * bam_dup1( bam1_t *src )
134 bam1_t * bam_copy1(bam1_t *bdst, bam1_t *bsrc)
135 bam_index_t *bam_index_load(char *f )
137 void bam_index_destroy(bam_index_t *idx)
139 int bam_parse_region(bam_header_t *header, char *str, int *ref_id, int *begin, int *end)
141 bam_plbuf_t *bam_plbuf_init(bam_pileup_f func, void *data)
143 int bam_fetch(bamFile fp, bam_index_t *idx, int tid, int beg, int end, void *data, bam_fetch_f func)
145 int bam_plbuf_push(bam1_t *b, bam_plbuf_t *buf)
147 void bam_plbuf_destroy(bam_plbuf_t *buf)
149 int bam_read1(bamFile fp, bam1_t *b)
151 int bam_write1( bamFile fp, bam1_t *b)
153 bam_header_t *bam_header_init()
155 int bam_header_write( bamFile fp, bam_header_t *header)
157 bam_header_t *bam_header_read( bamFile fp )
159 void bam_header_destroy(bam_header_t *header)
161 bam1_t * bam_dup1( bam1_t *src )
163 bam1_t * bam_copy1(bam1_t *bdst, bam1_t *bsrc)
165 uint8_t *bam_aux_get(bam1_t *b, char tag[2])
167 int bam_aux2i(uint8_t *s)
168 float bam_aux2f(uint8_t *s)
169 double bam_aux2d(uint8_t *s)
170 char bam_aux2A( uint8_t *s)
171 char *bam_aux2Z( uint8_t *s)
173 int bam_reg2bin(uint32_t beg, uint32_t end)
175 uint32_t bam_calend(bam1_core_t *c, uint32_t *cigar)
177 cdef extern from "sam.h":
179 ctypedef struct samfile_t_un:
184 ctypedef struct samfile_t:
189 samfile_t *samopen( char *fn, char * mode, void *aux)
191 int sampileup( samfile_t *fp, int mask, bam_pileup_f func, void *data)
193 void samclose(samfile_t *fp)
195 int samread(samfile_t *fp, bam1_t *b)
197 int samwrite(samfile_t *fp, bam1_t *b)
199 cdef extern from "faidx.h":
201 ctypedef struct faidx_t:
204 int fai_build(char *fn)
206 void fai_destroy(faidx_t *fai)
208 faidx_t *fai_load(char *fn)
210 char *fai_fetch(faidx_t *fai, char *reg, int *len)
212 cdef extern from "pysam_util.h":
214 int pysam_bam_plbuf_push(bam1_t *b, bam_plbuf_t *buf, int cont)
216 int pysam_get_pos( bam_plbuf_t *buf)
218 int pysam_get_tid( bam_plbuf_t *buf)
220 bam_pileup1_t * pysam_get_pileup( bam_plbuf_t *buf)
222 int pysam_dispatch(int argc, char *argv[] )
224 # stand-in functions for samtools macros
225 void pysam_bam_destroy1( bam1_t * b)
227 # add *nbytes* into the variable length data of *src* at *pos*
228 bam1_t * pysam_bam_update( bam1_t * b,
233 # translate char to unsigned char
234 unsigned char pysam_translate_sequence( char s )
236 # stand-ins for samtools macros
237 uint32_t * pysam_bam1_cigar( bam1_t * b)
238 char * pysam_bam1_qname( bam1_t * b)
239 uint8_t * pysam_bam1_seq( bam1_t * b)
240 uint8_t * pysam_bam1_qual( bam1_t * b)
241 uint8_t * pysam_bam1_aux( bam1_t * b)
243 # iterator implemenation
244 ctypedef struct bam_fetch_iterator_t:
247 bam_fetch_iterator_t* bam_init_fetch_iterator(bamFile fp, bam_index_t *idx, int tid, int beg, int end)
249 bam1_t * bam_fetch_iterate(bam_fetch_iterator_t *iter)
251 void bam_cleanup_fetch_iterator(bam_fetch_iterator_t *iter)