X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=pysam.git;a=blobdiff_plain;f=pysam%2Fcsamtools.pxd;fp=pysam%2Fcsamtools.pxd;h=a4902830719b96aaf8d05fb5c4aa6086d5f892a1;hp=4ec74e3693c86aea8cc7052db6ace9a770c6bb6d;hb=920cc77ed26707a0d92f9e436121b61d84bde627;hpb=8ab946e230447a6fe686edabc5e3cfa445da1721 diff --git a/pysam/csamtools.pxd b/pysam/csamtools.pxd index 4ec74e3..a490283 100644 --- a/pysam/csamtools.pxd +++ b/pysam/csamtools.pxd @@ -56,18 +56,17 @@ 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 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": @@ -236,6 +235,9 @@ cdef extern from "bam.h": 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*" @@ -375,7 +377,8 @@ cdef extern from "pysam_util.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 ) @@ -385,7 +388,30 @@ cdef extern from "pysam_util.h": # void pysam_dump_glf( glf1_t * g, bam_maqcns_t * c ) -# need to declare all C fields and methods here +#################################################################### +# 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 ) + cdef class AlignedRead: # object that this AlignedRead represents @@ -420,12 +446,54 @@ cdef class Samfile: 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 @@ -433,4 +501,46 @@ cdef class IteratorRowAll(IteratorRow): 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 +