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
cdef extern from "stdint.h":
- ctypedef int int64_t
+ ctypedef int int8_t
+ ctypedef int int16_t
ctypedef int int32_t
- ctypedef int uint32_t
+ ctypedef int int64_t
ctypedef int uint8_t
+ ctypedef int uint16_t
+ ctypedef int uint32_t
ctypedef int uint64_t
cdef extern from "bam.h":
char *text
ctypedef struct bam_index_t:
- pass
+ int32_t n
+ uint64_t n_no_coor
ctypedef struct bam_plbuf_t:
pass
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)
##################################################
uint32_t bam_calend(bam1_core_t *c, uint32_t *cigar)
+ int bam_aux_type2size( int )
+
+
cdef extern from *:
ctypedef char* const_char_ptr "const char*"
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
+#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 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
+# 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 * )
+# void bam_maqindel_ret_destroy( bam_maqindel_ret_t * )
- bam_maqindel_opt_t *bam_maqindel_opt_init()
+# 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 )
+# 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":
int pysam_reference2tid( bam_header_t *header, char * s )
- void pysam_set_stderr( FILE * file )
+ void pysam_set_stderr( int fd )
+ void pysam_unset_stderr()
+
+ # 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 )
+# uint32_t pysam_glf_depth( glf1_t * g )
- void pysam_dump_glf( glf1_t * g, bam_maqcns_t * c )
+# void pysam_dump_glf( glf1_t * g, bam_maqcns_t * c )
+
+####################################################################
+# Utility types
+
+ctypedef struct __iterdata:
+ samfile_t * samfile
+ bam_iter_t iter
+ faidx_t * fastafile
+ int tid
+ char * seq
+ int seq_len
+
+####################################################################
+#
+# Exposing pysam extension classes
+#
+# Note: need to declare all C fields and methods here
+#
+cdef class Fastafile:
+ cdef char * _filename
+ # pointer to fastafile
+ cdef faidx_t * fastafile
+
+ cdef char * _fetch( self, char * reference, int start, int end, int * length )
-# need to declare all C fields and methods here
cdef class AlignedRead:
# object that this AlignedRead represents
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
# 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)
cdef char * _getrname( self, int tid )
+cdef class PileupProxy:
+ cdef bam_pileup1_t ** plp
+ cdef int tid
+ cdef int pos
+ cdef int n_pu
+
+cdef class PileupRead:
+ cdef AlignedRead _alignment
+ cdef int32_t _qpos
+ cdef int _indel
+ cdef int _level
+ cdef uint32_t _is_del
+ cdef uint32_t _is_head
+ cdef uint32_t _is_tail
+
+cdef class IteratorRow:
+ pass
+
+cdef class IteratorRowRegion(IteratorRow):
+ cdef bam_iter_t iter # iterator state object
+ cdef bam1_t * b
+ cdef int retval
+ cdef Samfile samfile
+ cdef samfile_t * fp
+ # true if samfile belongs to this object
+ cdef int owns_samfile
+
+ cdef bam1_t * getCurrent( self )
+
+ cdef int cnext(self)
+
+cdef class IteratorRowAll(IteratorRow):
+ cdef bam1_t * b
+ cdef samfile_t * fp
+ cdef int owns_samfile
+ cdef bam1_t * getCurrent( self )
+ cdef int cnext(self)
+
+cdef class IteratorRowAllRefs(IteratorRow):
+ cdef Samfile samfile
+ cdef int tid
+ cdef IteratorRowRegion rowiter
+
+cdef class IteratorRowSelection(IteratorRow):
+ cdef bam1_t * b
+ cdef int current_pos
+ cdef samfile_t * fp
+ cdef positions
+ # true if samfile belongs to this object
+ cdef int owns_samfile
+
+ cdef bam1_t * getCurrent( self )
+
+ cdef int cnext(self)
+
+cdef class IteratorColumn:
+
+ # result of the last plbuf_push
+ cdef IteratorRowRegion iter
+ cdef int tid
+ cdef int pos
+ cdef int n_plp
+ cdef int mask
+ cdef const_bam_pileup1_t_ptr plp
+ cdef bam_plp_t pileup_iter
+ cdef __iterdata iterdata
+ cdef Samfile samfile
+ cdef Fastafile fastafile
+ cdef stepper
+ cdef int max_depth
+
+ cdef int cnext(self)
+ cdef char * getSequence( self )
+ cdef setMask( self, mask )
+ cdef setupIteratorData( self,
+ int tid,
+ int start,
+ int end,
+ int reopen = ? )
+
+ cdef reset( self, tid, start, end )
+
+cdef class IteratorColumnRegion(IteratorColumn):
+ cdef int start
+ cdef int end
+ cdef int truncate
+
+cdef class IteratorColumnAllRefs(IteratorColumn):
+ pass
+
+cdef class IndexedReads:
+ cdef Samfile samfile
+ cdef samfile_t * fp
+ cdef index
+ # true if samfile belongs to this object
+ cdef int owns_samfile
+
+