jpayne@69: # cython: language_level=3 jpayne@69: from pysam.libchtslib cimport * jpayne@69: jpayne@69: cdef extern from "htslib_util.h": jpayne@69: jpayne@69: # add *nbytes* into the variable length data of *src* at *pos* jpayne@69: bam1_t * pysam_bam_update(bam1_t * b, jpayne@69: size_t nbytes_old, jpayne@69: size_t nbytes_new, jpayne@69: uint8_t * pos) jpayne@69: jpayne@69: # now: static jpayne@69: int aux_type2size(int) jpayne@69: jpayne@69: char * pysam_bam_get_qname(bam1_t * b) jpayne@69: uint32_t * pysam_bam_get_cigar(bam1_t * b) jpayne@69: uint8_t * pysam_bam_get_seq(bam1_t * b) jpayne@69: uint8_t * pysam_bam_get_qual(bam1_t * b) jpayne@69: uint8_t * pysam_bam_get_aux(bam1_t * b) jpayne@69: int pysam_bam_get_l_aux(bam1_t * b) jpayne@69: char pysam_bam_seqi(uint8_t * s, int i) jpayne@69: jpayne@69: uint8_t pysam_get_qual(bam1_t * b) jpayne@69: uint32_t pysam_get_n_cigar(bam1_t * b) jpayne@69: void pysam_set_qual(bam1_t * b, uint8_t v) jpayne@69: void pysam_set_n_cigar(bam1_t * b, uint32_t v) jpayne@69: void pysam_update_flag(bam1_t * b, uint16_t v, uint16_t flag) jpayne@69: jpayne@69: jpayne@69: from pysam.libcalignmentfile cimport AlignmentFile, AlignmentHeader jpayne@69: ctypedef AlignmentFile AlignmentFile_t jpayne@69: jpayne@69: jpayne@69: # Note: need to declare all C fields and methods here jpayne@69: cdef class AlignedSegment: jpayne@69: jpayne@69: # object that this AlignedSegment represents jpayne@69: cdef bam1_t * _delegate jpayne@69: jpayne@69: # the header that a read is associated with jpayne@69: cdef readonly AlignmentHeader header jpayne@69: jpayne@69: # caching of array properties for quick access jpayne@69: cdef object cache_query_qualities jpayne@69: cdef object cache_query_alignment_qualities jpayne@69: cdef object cache_query_sequence jpayne@69: cdef object cache_query_alignment_sequence jpayne@69: jpayne@69: # add an alignment tag with value to the AlignedSegment jpayne@69: # an existing tag of the same name will be replaced. jpayne@69: cpdef set_tag(self, tag, value, value_type=?, replace=?) jpayne@69: jpayne@69: # get an alignment tag from the AlignedSegment jpayne@69: cpdef get_tag(self, tag, with_value_type=?) jpayne@69: jpayne@69: # return true if tag exists jpayne@69: cpdef has_tag(self, tag) jpayne@69: jpayne@69: # returns a valid sam alignment string jpayne@69: cpdef to_string(self) jpayne@69: jpayne@69: # returns a valid sam alignment string (deprecated) jpayne@69: cpdef tostring(self, htsfile=*) jpayne@69: jpayne@69: jpayne@69: cdef class PileupColumn: jpayne@69: cdef const bam_pileup1_t ** plp jpayne@69: cdef int tid jpayne@69: cdef int pos jpayne@69: cdef int n_pu jpayne@69: cdef AlignmentHeader header jpayne@69: cdef uint32_t min_base_quality jpayne@69: cdef kstring_t buf jpayne@69: cdef char * reference_sequence jpayne@69: jpayne@69: cdef class PileupRead: jpayne@69: cdef int32_t _qpos jpayne@69: cdef AlignedSegment _alignment jpayne@69: cdef int _indel jpayne@69: cdef int _level jpayne@69: cdef uint32_t _is_del jpayne@69: cdef uint32_t _is_head jpayne@69: cdef uint32_t _is_tail jpayne@69: cdef uint32_t _is_refskip jpayne@69: jpayne@69: # factory methods jpayne@69: cdef AlignedSegment makeAlignedSegment( jpayne@69: bam1_t * src, jpayne@69: AlignmentHeader header) jpayne@69: jpayne@69: cdef PileupColumn makePileupColumn( jpayne@69: const bam_pileup1_t ** plp, jpayne@69: int tid, jpayne@69: int pos, jpayne@69: int n_pu, jpayne@69: uint32_t min_base_quality, jpayne@69: char * reference_sequence, jpayne@69: AlignmentHeader header) jpayne@69: jpayne@69: cdef PileupRead makePileupRead(const bam_pileup1_t * src, jpayne@69: AlignmentHeader header) jpayne@69: jpayne@69: cdef uint32_t get_alignment_length(bam1_t * src)