-
cdef extern from "string.h":
ctypedef int size_t
void *memcpy(void *dst,void *src,size_t len)
void qsort(void *base, size_t nmemb, size_t size,
int (*compar)(void *,void *))
+cdef extern from "math.h":
+ double sqrt(double x)
+
cdef extern from "stdio.h":
ctypedef struct FILE:
pass
cdef extern from "Python.h":
long _Py_HashPointer(void*)
+ FILE* PyFile_AsFile(object)
+
+cdef extern from "fileobject.h":
+ ctypedef class __builtin__.file [object PyFileObject]:
+ pass
cdef extern from "razf.h":
pass
ctypedef int uint8_t
ctypedef int uint64_t
-
cdef extern from "bam.h":
+ # constants
+ int BAM_DEF_MASK
# IF _IOLIB=2, bamFile = BGZF, see bgzf.h
# samtools uses KNETFILE, check how this works
char *text
ctypedef struct bam_index_t:
- pass
+ int32_t n
+ uint64_t n_no_coor
ctypedef struct bam_plbuf_t:
pass
+ ctypedef struct pair64_t:
+ uint64_t u, v
+
ctypedef struct bam_iter_t:
- pass
+ int from_first
+ int tid, beg, end, n_off, i, finished
+ uint64_t curr_off
+ pair64_t *off
+
+ # ctypedef __bam_iter_t * bam_iter_t
bam1_t * bam_init1()
void bam_destroy1(bam1_t *)
ctypedef struct bam_plp_t:
pass
+ ctypedef bam_pileup1_t * const_bam_pileup1_t_ptr "const bam_pileup1_t *"
+
ctypedef int (*bam_plp_auto_f)(void *data, bam1_t *b)
bam_plp_t bam_plp_init( bam_plp_auto_f func, void *data)
int bam_plp_push( bam_plp_t iter, bam1_t *b)
- bam_pileup1_t *bam_plp_next( bam_plp_t iter, int *_tid, int *_pos, int *_n_plp)
- bam_pileup1_t *bam_plp_auto( bam_plp_t iter, int *_tid, int *_pos, int *_n_plp)
+ bam_pileup1_t * bam_plp_next( bam_plp_t iter, int *_tid, int *_pos, int *_n_plp)
+ bam_pileup1_t * bam_plp_auto( bam_plp_t iter, int *_tid, int *_pos, int *_n_plp)
void bam_plp_set_mask(bam_plp_t iter, int mask)
void bam_plp_reset(bam_plp_t iter)
void bam_plp_destroy(bam_plp_t iter)
+ void bam_plp_set_maxcnt(bam_plp_t iter, int maxcnt)
##################################################
- int bam_read1(bamFile fp, bam1_t *b)
-
+ int bam_read1( bamFile fp, bam1_t *b)
+ int bam_validate1( bam_header_t *header, bam1_t *b)
int bam_write1( bamFile fp, bam1_t *b)
bam_header_t *bam_header_init()
uint8_t *bam_aux_get(bam1_t *b, char tag[2])
- int bam_aux2i(uint8_t *s)
+ int32_t bam_aux2i(uint8_t *s)
float bam_aux2f(uint8_t *s)
double bam_aux2d(uint8_t *s)
char bam_aux2A( uint8_t *s)
uint32_t bam_calend(bam1_core_t *c, uint32_t *cigar)
+cdef extern from *:
+ ctypedef char* const_char_ptr "const char*"
+
cdef extern from "sam.h":
ctypedef struct samfile_t_un:
samfile_t_un x
bam_header_t *header
- samfile_t *samopen( char *fn, char * mode, void *aux)
+ samfile_t *samopen( const_char_ptr fn, char * mode, void *aux)
int sampileup( samfile_t *fp, int mask, bam_pileup_f func, void *data)
int samwrite(samfile_t *fp, bam1_t *b)
+ int bam_prob_realn(bam1_t *b, char *ref)
+ int bam_cap_mapQ(bam1_t *b, char *ref, int thres)
+
+
+#cdef extern from "glf.h":
+# ctypedef struct glf1_t:
+# pass
+
+#cdef extern from "bam_maqcns.h":
+#
+# ctypedef struct bam_maqcns_t:
+# float het_rate, theta
+# int n_hap, cap_mapQ, errmod, min_baseQ
+# float eta, q_r
+# double *fk, *coef
+# double *lhet
+# void *aux
+
+# glf1_t *bam_maqcns_glfgen(int n,
+# bam_pileup1_t *pl,
+# uint8_t ref_base,
+# bam_maqcns_t *bm)
+
+# ctypedef struct bam_maqindel_opt_t:
+# int q_indel
+# float r_indel
+# float r_snp
+# int mm_penalty, indel_err, ambi_thres
+
+# uint32_t bam_maqcns_call(int n, bam_pileup1_t *pl, bam_maqcns_t *bm)
+# bam_maqcns_t * bam_maqcns_init()
+# void bam_maqcns_destroy(bam_maqcns_t *bm)
+# void bam_maqcns_prepare(bam_maqcns_t *bm)
+
+# uint32_t glf2cns(glf1_t *g, int q_r)
+
+# int BAM_ERRMOD_MAQ2
+# int BAM_ERRMOD_MAQ
+# int BAM_ERRMOD_SOAP
+
+# ctypedef struct bam_maqindel_ret_t:
+# int indel1
+# int indel2
+# int cnt1
+# int cnt2
+# int cnt_anti
+# int cnt_ref
+# int cnt_ambi
+# char *s[2]
+# int gt
+# int gl[2]
+# int q_cns
+# int q_ref
+
+# void bam_maqindel_ret_destroy( bam_maqindel_ret_t * )
+
+# bam_maqindel_opt_t *bam_maqindel_opt_init()
+
+# bam_maqindel_ret_t * bam_maqindel(int n,
+# int pos,
+# bam_maqindel_opt_t * mi,
+# bam_pileup1_t * pl,
+# char *ref,
+# int _n_types,
+# int * _types )
+
+
cdef extern from "faidx.h":
ctypedef struct faidx_t:
char *faidx_fetch_seq(faidx_t *fai, char *c_name,
int p_beg_i, int p_end_i, int *len)
+
cdef extern from "pysam_util.h":
int pysam_pileup_next(bam1_t *b,
# translate char to unsigned char
unsigned char pysam_translate_sequence( char s )
-
+ unsigned char * bam_nt16_table
+
+ int pysam_reference2tid( bam_header_t *header, char * s )
+
+ void pysam_set_stderr( FILE * file )
+
+ # return mapped/unmapped reads on tid
+ uint32_t pysam_get_mapped( bam_index_t *idx, int tid )
+ uint32_t pysam_get_unmapped( bam_index_t *idx, int tid )
+
+# uint32_t pysam_glf_depth( glf1_t * g )
+
+# void pysam_dump_glf( glf1_t * g, bam_maqcns_t * c )
+
+# need to declare all C fields and methods here
+cdef class AlignedRead:
+
+ # object that this AlignedRead represents
+ cdef bam1_t * _delegate
+
+cdef class Samfile:
+ cdef char * _filename
+ # pointer to samfile
+ cdef samfile_t * samfile
+ # pointer to index
+ cdef bam_index_t *index
+ # true if file is a bam file
+ cdef int isbam
+ # true if not a file but a stream
+ cdef int isstream
+ # true if file is not on the local filesystem
+ cdef int isremote
+ # current read within iteration
+ cdef bam1_t * b
+ # file opening mode
+ cdef char * mode
+
+ # beginning of read section
+ cdef int64_t start_offset
+
+ cdef bam_header_t * _buildHeader( self, new_header )
+ cdef bam1_t * getCurrent( self )
+ cdef int cnext(self)
+
+ # write an aligned read
+ cpdef int write( self, AlignedRead read )
+
+ cdef char * _getrname( self, int tid )
+
+cdef class IteratorRow:
+ pass
+
+cdef class IteratorRowAll(IteratorRow):
+ cdef bam1_t * b
+ cdef samfile_t * fp
+ # true if samfile belongs to this object
+ cdef int owns_samfile
+
+ cdef bam1_t * getCurrent( self )
+
+ cdef int cnext(self)
+
+